Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SYSTEM DATE

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
I am trying to get the year from the system date but I keep getting a syntax error. I am using this to get the system date year:

year (today ())

Any help would be appreciated.

Thank You,
rjoshi2

Code
DateTime ldt_date
ldt_date = DateTime( Date("Dec-31-2099") , Now())

if year :)ldt_date) = year (today ())then
UPDATE PROGRAM
SET YTD_NO = nvl( YTD_NO , 0 ) + 1,
YTD_AMT = nvl( YTD_AMT , 0 ) + :ll_ramount ;
end if
 
But today into a variable and get the year from the variable. That should fix your syntax error and get you what you want.

Daniel
 
what type of varivle should var_datetime
 
It is true that Year() is only for date datatype variables, but u can use it with the Today() function and u won't get any problem. Please make sure to remove the ":" before the ldt_Date variable, so u can avoid the "Syntax Error" problem. An example of code that will work is:

Date ldt_Date

ldt_Date = Date("Dec-31-2099")
If Year(ldt_Date) = Year(Today()) Then
UPDATE PROGRAM
SET YTD_NO = nvl( YTD_NO , 0 ) + 1,
YTD_AMT = nvl( YTD_AMT , 0 ) + :ll_ramount;
End If
 
I have tried this:

DateTime ltd_sys_date
ltd_sys_date = DateTime(today ())

if year :)ldt_date) = year (date(ltd_sys_date)) then
UPDATE PROGRAM
SET YTD_NO = nvl( YTD_NO , 0 ) + 1,
YTD_AMT = nvl( YTD_AMT , 0 ) + :ll_ramount ;
end if

I get error when compile:
Bad argument list for function: year
 
This seems to work:

DateTime ldt_date
Date ltd_sys_date

ldt_date = DateTime( Date("Dec-31-2099") , Now())
ltd_sys_date = Date("Dec-31-2099")

if year (date(ldt_date)) = year (date(ltd_sys_date)) then
UPDATE MAIN
SET YTD_NO = nvl( YTD_NO , 0 ) + 1,
YTD_AMT = nvl( YTD_AMT , 0 ) + :ll_ramount ;
end if
 
You are using :ldt_date as an argument for the Year() function. Variables prefixed with a colon are host-variables that are used only in SQL. Colons are not required in PowerScript.

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top