?
Solved

Get date without minutes and seconds?

Posted on 2004-11-03
5
Medium Priority
?
513 Views
Last Modified: 2006-11-17
Hello
In a stored proc I want to get todays date in the form dd/mm/yy and compare it against some datgetime fields in my tables how can I do this?
0
Comment
Question by:auk_ie
5 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 900 total points
ID: 12490106
SELECT convert( datetime, CONVERT( char(10), getdate(), 120 ) )

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20293779.html
0
 
LVL 10

Expert Comment

by:imrancs
ID: 12490114
see the CONVERT function help in BOL for complete list of formats
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12490116
0
 
LVL 11

Expert Comment

by:ram2098
ID: 12490607
This gives you the date in dd/mm/yy format...

SELECT CONVERT(VARCHAR(10),GETDATE(),3)

If you want it in dd/mm/yyyy format..you can use

SELECT CONVERT(VARCHAR(10),GETDATE(),103)

0
 
LVL 16

Assisted Solution

by:muzzy2003
muzzy2003 earned 100 total points
ID: 12503209
If you want to compare against a datetime field, then the actual format is irrelevant, it is just that you want to strip the time element from the date. Stick with the format value 120 that sajuks suggested (ODBC canonical with century) - while 103 does indeed give you dd/mm/yyyy, its conversion to datetime for the comparison will be affected by your system locale.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

850 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