วันพฤหัสบดีที่ 19 มีนาคม พ.ศ. 2552

Date Time without time in SQL

เมื่อต้องการเฉพาะวันที่แต่ไม่เอาเวลามาด้วย :

Select Convert (varchar(12),getdate(),101) --> 03/19/2009

Select Convert (varchar(12),getdate(),1) --> 03/19/09

The 101 means “mm/dd/yyyy” format, but there are a bunch of other codes you can use. 108 will return just the time “hh:mm:ss” for instance.


0 ความคิดเห็น: