Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

BIGINT date format in comparison Expand / Collapse
Author
Message
Posted Wednesday, December 18, 2013 3:48 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, September 22, 2014 3:48 AM
Points: 49, Visits: 237
What is the best way to filter out records which has a orderdate column in bigint format ?
Post #1524009
Posted Wednesday, December 18, 2013 4:05 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 10:40 AM
Points: 2,480, Visits: 3,023
Can u give some more information? Perhaps add some samples to clarify your question?



I assume you have a table with a column with datatype BIGINT. You use that column to store date-values, like the sample below.

ID...BigINT_Date
1.....20131210
2.....20131211
3.....20131212
4.....20131213

To filter the data is specific to the notation used to store the date value. If it is stored in yyyymmdd format (like my sample) you could just filter using the < and > comparison. If it is stored in a mmddyyyy format it will be more complicated. You first need to convert the value to a datetime datatype and then use the < and > comparison.


But my assumption about your situation could be completely wrong, so please give us more information!!


** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Post #1524019
Posted Wednesday, December 18, 2013 4:32 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, September 22, 2014 3:48 AM
Points: 49, Visits: 237
Thanks a lot for the quick reply.

My datetime is stored in UTC format.



Eg. 1299781800000 ( GMT: Thu, 10 Mar 2011 18:30:00 GMT, Your time zone: 11/3/2011 00:00:00 GMT+5.5)
Post #1524026
Posted Wednesday, December 18, 2013 11:36 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:11 PM
Points: 35,772, Visits: 32,441
SQL Kidu (12/18/2013)
What is the best way to filter out records which has a orderdate column in bigint format ?


The BEST way to do this is to attack the root cause of the problem. Dates should never be stored as BIGINT. You would do well to fix the table and the code that uses it. That would prevent the current problem and all future problems with this column.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1524267
Posted Wednesday, December 18, 2013 11:31 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, September 22, 2014 3:48 AM
Points: 49, Visits: 237
Yeah. Make sense. This one is creating lot of confusion.. Will see to it.

Thanks BTW :)
Post #1524451
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse