473,322 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

convert current date to integer as in YYYYMMDD

I have a bit trouble in converting CURRENT DATE into a integer type as YYYYMMDD.

The following script is trying to find a day matching a date column with integer type with yesterday (CURRENT DATE - 1 DAY).

[column name of integer type] = YEAR(CURRENT DATE - 1 DAY) * 10000 + MONTH(CURRENT DATE - 1 DAY) * 100 + DAY(CURRENT DATE - 1 DAY)

It doesnt give the correct result. Actually the calculation result from right side of the equation doesnt match with any values in the column. Can anyone help me figure out what's wrong with the above statement?
Apr 10 '07 #1
3 84088
Snib
24
I have just tried you SQL with the following:

select YEAR(CURRENT DATE - 1 DAY) * 10000 + MONTH(CURRENT DATE - 1 DAY)
* 100 + DAY(CURRENT DATE - 1 DAY)
from sysibm.sysdummy1
;

and got the result:

20070410

which all seems to be fine to me!

What I suggest you do is try running you SQL but type in the integer value you are looking for to verify that the data in the column it is matching against contains what you expect.

Alternatively you could run something like this:

select Integer_date_column, count(*)
from your_table
group by Integrate_date_column;

This will give you a count of how frequently each integer date value occurs on your table. Then try putting one of these integer values into you SQL to verify it is selecting correctly.

Regards

Snib
Apr 11 '07 #2
v0rtex
1
A simpler method might be:

select int(replace(char(current date - 1 day, ISO),'-',''))
from sysibm/sysdummy1
May 17 '07 #3
Thank you both.
Will try the suggestion and let you know the status.

Regards,
Akhila
Mar 20 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Chris | last post by:
Sorry, This should be simple, but brain is hurting... How do I convert a Current Time to a Decimal 6,0 (HMS)? There must be a cleaner way then this: Insert into Table Values Dec(...
6
by: vijayk | last post by:
Hi all, I have a field which has data as YYYYMMDD, and I have to find the age of the person by substracting it from current date. can you please please advice... thanks
2
by: markryde | last post by:
Hello, I am trying to add the current date to a file name in python script like thus: import os import sys import rpm import time import datetime
5
by: Extremest | last post by:
I have a bunch of dates in a couple different formats. I would like to convert them to epoch. The dates are like this Mon, 12 Jun 2006 09:18:22 GMT 12 Jun 2006 10:37:28 GMT I can do this in...
6
by: phforum | last post by:
If user input the date is 2006-07-01. How to convert it to last year 2005-07-01? Thanks
5
by: Pontifex | last post by:
Hi all, 1. I have a large set of web pages and at the top of each page I have a script that prints out the current date. It's always in the body. Is there a way to put that script in a .js...
2
by: rpboll | last post by:
Is there a function that stamps the FISCAL Date (Starting from October)? I am trying to generate a Fiscal Date and an AutoNumber for a key field. Thanks for any suggestions. RBollinger
1
by: shiznaw | last post by:
Private Function rprtdate() Dim rprtdates As Date Dim 1mnth As Integer 1mnth= Month(Date) + Month(DateSerial(Year(Date), Month(Date) + 1, Day(Date))) Select Case Frame35.Value 'the following...
4
by: Steve Rainbird | last post by:
Is there a way in DB2 I can get the current date and time formatted. In Oracle I could do the following select to_char(sysdate,'yyyymmdd') from dual returns 20070718
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.