You must Sign In to post a response.
  • Category: .NET

    How to pass the datetime value from to MS SQL server for query?

    The forum thread has not been reviewed by Editors yet. Readers are advised to use their best judgement before accessing this thread.
    This thread will be reviewed shortly.
    If you think this thread contain inappropriate content, please report to webmaster.
    Dear All

    I have a page which will get data from SQL server. After some selection on the data (datetime value), we will use a selected datetime value to search the MS SQL server's tables for further query results.

    I encountered the problem is .... after the use selection of the datetime value, the datetime value is in "MM/DD/YYYY HH:MM:SS". However the MS SQL server is only allow datetime format in "DD/MM/YYYY HH:MM:SS". So, could any one help me how to make things work? How to reformat the datetime before I pass it back to the MS SQL server for query?

    Thanks a lot
  • #58094
    use this link for datetime convertion

  • #58097
    first make sure that after selecting date shlold be in the format MM/dd/yyyy HH:mm:ss am/pm
    then u can insert in the database.....


  • #58099
    than try to change the date formnat format by using the following code:

  • #58100
    you can convert the date fromat in to SQL date formats by using

    SET @DT='12-22-2006 10:18:34 pm'

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.