Hi all !
I have a datetime column in SQL Server 2000 that gives me data like this 10/27/2010 12:57:49 pm and I want to query this column just have return hh:mm pm like 12:57 pm. Which query I use to fetch this column. I am using this query in C# windows application.
Loading

Riyaz AkhtarPosted Jul 25, 2013, 9:06 AM
I have modified TxtGen method, also i have modified ur sql query, please correct according to ur table schema. here STA i have considered the column which u want to get the value in AM/Pm format.
Let me know if u are still facing any issue.
Santosh KumarPosted Aug 1, 2013, 8:06 AM
Sanjeeb LenkaPosted Jul 29, 2013, 1:05 PM
select TrainNo,TrainNameE,TrainNameH,RIGHT(CONVERT(VARCHAR, CAST(STA as datetime), 108),8) AS STA,DLY,PlatNo,Pf_end,STS,Coach_sequence from currentdata
Santosh KumarPosted Jul 29, 2013, 12:23 PM
Santosh KumarPosted Jul 26, 2013, 12:07 PM
If you know better link for study about these time conversion formulas, please provide.
I would be highly obliged and thankful for your help.
Santosh KumarPosted Jul 26, 2013, 2:59 AM
So thank you again for giving your precious time for me.
Riyaz AkhtarPosted Jul 25, 2013, 7:55 AM
Iftikar HussainPosted Jul 25, 2013, 7:53 AM
Regards,
Iftikar
Santosh KumarPosted Jul 25, 2013, 7:24 AM
Riyaz AkhtarPosted Jul 25, 2013, 7:11 AM
Iftikar HussainPosted Jul 25, 2013, 7:08 AM
Try like this
Regards,
Iftikar
Santosh KumarPosted Jul 25, 2013, 6:48 AM
My data fields as
Desired ArrTime in Text File as 2:45 PM Please Check C# code I have attached. Thanks a lot.
Riyaz AkhtarPosted Jul 25, 2013, 4:54 AM
here dt is the column name where datetime is stored.
Please let me know if u r facing any issue.
Riyaz AkhtarPosted Jul 25, 2013, 4:33 AM
Sanjeeb LenkaPosted Jul 25, 2013, 4:29 AM
Refer to this link
http://blog.sqlauthority.com/2009/08/06/sql-server-get-time-in-hourminute-format-from-a-datetime-get-date-part-only-from-datetime/
Jignesh TrivediPosted Jul 25, 2013, 4:13 AM
hi,
I think using Dataname you can achieve this
select DATENAME(HH ,GETDATE()) + ':' + DATENAME(MI ,GETDATE())
hope this will help you.