Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Date Time Problem

Former Member
0 Likes
1,078

Dear Experts ,

I am facing Date Time Problem , the problem is :-

My process is working fine except for example:-

Date is : 25.06.2009 Time 23:59:55

But during program execution the system saves date 26.06.2009 , which according to system has to be 25.06.2009, This only happens for last minute ex. between 23:59:00 to 23:59:59

So what will i do to save the record in the same date.

Ankesh Jindal

10 REPLIES 10
Read only

Former Member
0 Likes
1,047

Hi ankesh,

Hope you have used SY-DATUM and SY-UZEIT.

If your system date is 26.06.09 it will show 26.06.09.

As concerned to time if that is the issue check with basis they will help you with server date & time.

Re,Manas

Read only

Former Member
0 Likes
1,047

You can do one thing..

Check the time in code as below :

if time = '23:59:59'.

date = date - 1.

endif.

Read only

Former Member
0 Likes
1,047

What fn module are you using. Can you give technical details

Read only

Former Member
0 Likes
1,047

Well i think the problem is that you might be assigning system Date and Time to your variables, too soon in your code before you update/insert into database table. If that is the case then assign the system Date and time to your variables just before your Update Database Table code...

Read only

0 Likes
1,047

To Naresh :-

This logic cannot be applied bcos at that time system date is coming right but at the time of appending into table it is being changed by new date.

To Tripal Singh :-

Yes u r rite but it is a long process and we cant help the code to run near where databse is commiting

so the code will run there only ...

To Manas k Mishra

Hve already discussed the same issue with basis guy

To SugirdaNishanth

I am not using any FM .

Ankesh

Read only

0 Likes
1,047

Hi Ankesh,

SELECT * UP TO 1 ROWS

FROM zmailhist

WHERE vbeln EQ p_vbeln AND

kunnr EQ p_kunnr.

ENDSELECT.

IF sy-subrc = 0.

wa-vbeln = p_vbeln.

wa-kunnr = p_kunnr.

wa-vsura = sy-uzeit.

wa-erdat = sy-datum.

INSERT INTO zmailhist VALUES wa.

IF sy-subrc = 0.

COMMIT WORK.

ENDIF.

CLEAR:wa.

I have used this piece of code to update my ztable with date & time. It works fine.

See if this helps you...Or plz paste your code.

Re,Manas

Read only

0 Likes
1,047

Oh! You have the Vice-Versa problem to what i was thinking, The Database has value of one day after than current date during last minute... Strange...

I was thinking that the database commit takes time and therefore Date has changed by that time but your variable have previous date...

Some Basic Points here

1) How much avg. run time does your program takes.

2) Where and when are you assigning the Date and time to variables.

3) When does the database commit occurs.

Read only

Former Member
0 Likes
1,047

Hi,

may be you are directly using sy-datum value in the update code, which gets executed only on commit... due to which after 23:59:59, the value of sy-datum changes to the next date.......

in this case its better not to use sy-datum in the update code.... instead declare a local date variable and assign its value to sy-datum before the update code gets executed...... and then use that local variable instead of sy-datum in the update code which gets executed on commit.........

Regards,

Siddarth

Read only

0 Likes
1,047

hi ankesh ,

Check your code while saving and validate using such condition

as your update of date is correct when time is < 23:59:00 .

then add this condition i.e if time between 23:59:00 to 23:59:59 then sy-datum .

Regards

Deepak .

Read only

0 Likes
1,047

I got Soln for my problem . I used

GET TIME STAMP <Var-Name>.

Thanks