Link to home
Start Free TrialLog in
Avatar of Mohammad Aamir Qureshi
Mohammad Aamir QureshiFlag for Australia

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.ToString();

Help me

Thankx

Avatar of Mohammad Aamir Qureshi
Mohammad Aamir Qureshi
Flag of Australia image

ASKER

Error is this

""" Data Type mismatch in criteria expression "" 

Thankx
Avatar of Razzie_
Razzie_

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.
Or you can do this in your select statement:

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
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.ToString() +"'" ;
                        

and in database my record is in this Format
Sale_Time

4/10/2005
4/11/2005

Waiting

hai Yurich

i was use your statement( DateTime.Now.ToShortString()) but not Succeeded

Any other information
Hello melodiesoflife

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
Avatar of melodiesoflife
melodiesoflife

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial