Converting the current date to a number in SQL

This is handy if you find yourself needing to populate a numeric timestamp field (eight digit number, yyyymmdd) with the current date.

update TheFile                                                
set TheDate = Dec(Replace(Char(current date, ISO), '-', ''), 8, 0)
where TheSelection

Obviously, TheFile is the file you are populating, TheDate is the field and TheSelection is whatever selection criteria you happen to be using.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s