473,889 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert current date to integer as in YYYYMMDD

1 New Member
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 85013
Snib
24 New Member
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.sysdummy 1
;

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_co lumn, 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 New Member
A simpler method might be:

select int(replace(cha r(current date - 1 day, ISO),'-',''))
from sysibm/sysdummy1
May 17 '07 #3
AkhilaReddy
2 New Member
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
18944
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( Substr(Char(CURRENT TIMESTAMP),12,2) ||
6
26331
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
21087
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
5734
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 perl easily with the Date::Manip module but don't know how to do it in c#. Is there a way to do this or do I need to right something to parse each date?
6
9447
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
298
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 file and invoke it from inside the body?
2
6018
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
10010
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 if end user choses one month from the day chosen for reporting period Case Is = 3 rprtdates = Format(Calendar1.Value, "mm/dd/yy", vbSunday)
4
9256
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
9805
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11187
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5825
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6021
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.