SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to query formatted date in T-SQL?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

IndraG
Starting Member

Indonesia
3 Posts

Posted - 11/14/2012 :  02:13:49  Show Profile  Reply with Quote
I am more used to Access query, I want to query something with this kind of condition:
"Where Format(tblJBT.TglAkad, "dd/MM/yyyy") = #01/10/2012#"
The data includes hour and minutes, and with this Format function in Access, I can eliminate the hour and minutes, and query all data for that day (all hours and minutes within that day).

I know T-SQL do not accept Format function, but I do not know how to do the same kind of function in T-SQL for SQL Server.

Help, please?

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 11/14/2012 :  02:23:44  Show Profile  Visit webfred's Homepage  Reply with Quote
where YourCol >= '20121001' and YourCol < '20121002'


Too old to Rock'n'Roll too young to die.

Edited by - webfred on 11/14/2012 02:24:07
Go to Top of Page

IndraG
Starting Member

Indonesia
3 Posts

Posted - 11/14/2012 :  02:54:41  Show Profile  Reply with Quote
Well, to be honest, I have thought of that one. I thought there is a way to format a column during query? Simple if there is a need for it? Please?

Software Toko|Software Akuntansi|Sistem Informasi Akuntansi|Sistem Informasi Manajemen
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 11/14/2012 :  03:00:32  Show Profile  Visit webfred's Homepage  Reply with Quote
See/execute this example on how to convert and format the actual datetime to dd/mm/yyyy by using convert() with style argument:
select convert(varchar(10), getdate(),103)

More info here:
http://msdn.microsoft.com/de-de/library/ms187928.aspx


Too old to Rock'n'Roll too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22713 Posts

Posted - 11/17/2012 :  03:55:39  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by IndraG

Well, to be honest, I have thought of that one. I thought there is a way to format a column during query? Simple if there is a need for it? Please?

Software Toko|Software Akuntansi|Sistem Informasi Akuntansi|Sistem Informasi Manajemen


Formation is needed when you want to present that data to application layer. But in WHERE clause comparison it is not needed

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000