[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Date Time

Posted on 2005-04-11
9
Medium Priority
?
470 Views
Last Modified: 2008-01-16
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

0
Comment
9 Comments
 
LVL 2

Author Comment

by:Mohammad Aamir Qureshi
ID: 13750876
Error is this

""" Data Type mismatch in criteria expression "" 

Thankx
0
 
LVL 8

Expert Comment

by:Razzie_
ID: 13751278
What database are you using and what is your SQL query?
0
 
LVL 6

Expert Comment

by:melodiesoflife
ID: 13751318
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Expert Comment

by:apirnia
ID: 13755222
Or you can do this in your select statement:

Select CONVERT(CHAR(10), dtEntered, 101) AS DateEntered, .......
From ......
0
 
LVL 21

Expert Comment

by:Yurich
ID: 13756942
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
0
 
LVL 2

Author Comment

by:Mohammad Aamir Qureshi
ID: 13759298
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

0
 
LVL 2

Author Comment

by:Mohammad Aamir Qureshi
ID: 13759343
hai Yurich

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

Any other information
0
 
LVL 2

Author Comment

by:Mohammad Aamir Qureshi
ID: 13759367
Hello melodiesoflife

i want to search in database mean that

""""" HOW MUCH STOCK ITEM SALE TODAY"""""""

Best Answer will get 200 more points

Thankx

0
 
LVL 6

Accepted Solution

by:
melodiesoflife earned 1000 total points
ID: 13759412
Please try this SQL command:

"SELECT st.Stock_Name FROM Stock st , Sale s WHERE s.Stock_ID = st.Stock_id and  s.Sale_Time = CDate('" + DateTime.Today.Date.ToString() +"')";

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question