Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to convert date to mm/dd/yyyy or mm/dd/yy

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2006-01-17 : 11:45:16
How to convert the date to mm/dd/yyyy or mm/dd/yy in the select statement:

CONVERT(varchar(10), TAB_ccsNetSU.PDReceivedDate, 101) AS PDReceivedDate

on the vb front end i use the if condition as follows:

If Not IsDate("01/17/06") Then


Thank you very much for the information.

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-17 : 12:18:06
Check Books On Line - convert Function in T-SQL

The constant is 101 for mm/dd/yyyy
for mm/dd/yy the constant is 1

Check :
Select getdate()
Select convert(varchar, getdate(), 101)
Select convert(varchar, getdate(), 1)
in Query Analyzer
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-01-17 : 14:03:13
Why not transfer it as a "native" DateType and then compare it likewise in VB?

That prevents any country-specific formatting issues getting in your way.

Converting it to a text string, and back again, and messing around with trying ton get the formatting synchronised between your application and SQL Server is going to make you old before your time!

Presumably something like:

Dim myDate As Date

myDate = ... Some Date ...
If MyRecordSet("PDReceivedDate").Value = myDate Then ... some action ...

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-18 : 01:06:04
As Kristen said, dont use Format function when you compare dates. Use it when you display them

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -