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 AkhtarRank #2,275 · 619 reputationPosted Jul 25, 2013, 5:06 AM EDT
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.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 25, 2013, 12:13 AM EDT
hi,
I think using Dataname you can achieve this
select DATENAME(HH ,GETDATE()) + ':' + DATENAME(MI ,GETDATE())
hope this will help you.
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 25, 2013, 12:29 AM EDT
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/
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 25, 2013, 12:33 AM EDT
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 25, 2013, 12:54 AM EDT
here dt is the column name where datetime is stored.
Please let me know if u r facing any issue.
Santosh KumarRank #2,303 · 613 reputationPosted Jul 25, 2013, 2:48 AM EDT
My data fields as
Desired ArrTime in Text File as 2:45 PM Please Check C# code I have attached. Thanks a lot.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 3:08 AM EDT
Try like this
Regards,
Iftikar
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 25, 2013, 3:11 AM EDT
Santosh KumarRank #2,303 · 613 reputationPosted Jul 25, 2013, 3:24 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 3:53 AM EDT
Regards,
Iftikar
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 25, 2013, 3:55 AM EDT
Santosh KumarRank #2,303 · 613 reputationPosted Jul 25, 2013, 10:59 PM EDT
So thank you again for giving your precious time for me.
Santosh KumarRank #2,303 · 613 reputationPosted Jul 26, 2013, 8:07 AM EDT
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 KumarRank #2,303 · 613 reputationPosted Jul 29, 2013, 8:23 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 29, 2013, 9:05 AM EDT
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 KumarRank #2,303 · 613 reputationPosted Aug 1, 2013, 4:06 AM EDT