Mohammad Aamir Qureshi
asked on
Date Time
Hello Every Body
i want to add the time in DataBase like 4/11/2005 not 11:40:35 AM(not Whole Time ) How can i do that and when i search in
DataBase then what can i do . i using this statement but it give Error
DateTime.Today.Date.ToStri ng();
Help me
Thankx
i want to add the time in DataBase like 4/11/2005 not 11:40:35 AM(not Whole Time ) How can i do that and when i search in
DataBase then what can i do . i using this statement but it give Error
DateTime.Today.Date.ToStri
Help me
Thankx
What database are you using and what is your SQL query?
Please use:
DateTime.Now.ToString("dd/ MM/yyyy");
or
DateTime.Now.ToString("MM/ dd/yyyy");
depend on the type of your format. Both can cut off the time part.
DateTime.Now.ToString("dd/
or
DateTime.Now.ToString("MM/
depend on the type of your format. Both can cut off the time part.
Or you can do this in your select statement:
Select CONVERT(CHAR(10), dtEntered, 101) AS DateEntered, .......
From ......
Select CONVERT(CHAR(10), dtEntered, 101) AS DateEntered, .......
From ......
the safest way to store date in the database probably still would be in the recommended format for your database, one of which is:
"yyyy/dd/MM HH:mm:ss"
that's probably why you're getting errors - your database doesn't like any other formats
later, you can convert this format to anything you like when you extract your info, using any format suggested above. i would personally suggest to use
DateTime.Now.ToShortString () - that's universal and will use format specified in your regional settings
regards
"yyyy/dd/MM HH:mm:ss"
that's probably why you're getting errors - your database doesn't like any other formats
later, you can convert this format to anything you like when you extract your info, using any format suggested above. i would personally suggest to use
DateTime.Now.ToShortString
regards
ASKER
Welll
i m using MS Access having field of Sale_Time with Data type of Date/Time and my Query is this (For Searching)
"SELECT st.Stock_Name FROM Stock st , Sale s WHERE s.Stock_ID = st.Stock_id and s.Sale_Time = '" + DateTime.Today.Date.ToStri ng() +"'" ;
and in database my record is in this Format
Sale_Time
4/10/2005
4/11/2005
Waiting
i m using MS Access having field of Sale_Time with Data type of Date/Time and my Query is this (For Searching)
"SELECT st.Stock_Name FROM Stock st , Sale s WHERE s.Stock_ID = st.Stock_id and s.Sale_Time = '" + DateTime.Today.Date.ToStri
and in database my record is in this Format
Sale_Time
4/10/2005
4/11/2005
Waiting
ASKER
hai Yurich
i was use your statement( DateTime.Now.ToShortString ()) but not Succeeded
Any other information
i was use your statement( DateTime.Now.ToShortString
Any other information
ASKER
Hello melodiesoflife
i want to search in database mean that
""""" HOW MUCH STOCK ITEM SALE TODAY"""""""
Best Answer will get 200 more points
Thankx
i want to search in database mean that
""""" HOW MUCH STOCK ITEM SALE TODAY"""""""
Best Answer will get 200 more points
Thankx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
""" Data Type mismatch in criteria expression ""
Thankx