Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BIGINT date format in comparison


BIGINT date format in comparison

Author
Message
SQL Kidu
SQL Kidu
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 250
What is the best way to filter out records which has a orderdate column in bigint format ?
HanShi
HanShi
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3049 Visits: 3633
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’! **
SQL Kidu
SQL Kidu
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 250
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)
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45123 Visits: 39922
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
SQL Kidu
SQL Kidu
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 250
Yeah. Make sense. This one is creating lot of confusion.. Will see to it.

Thanks BTW Smile
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search