<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQR Dates</title>
	<atom:link href="http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/feed/" rel="self" type="application/rss+xml" />
	<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/</link>
	<description>When Peoplebooks Is Not Enough</description>
	<lastBuildDate>Mon, 23 Jan 2012 21:54:00 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: administrator</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-7680</link>
		<dc:creator>administrator</dc:creator>
		<pubDate>Mon, 23 Jan 2012 21:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-7680</guid>
		<description>If you write:

let $x = datenow()

You should make sure that $x is a date variable, not a string variable.  You do that in the setup block:

begin-setup
declare variable
date $x
end-declare
end-setup

Alternately, you could write:

let $x = datetostr(datenow(), &#039;mm/dd/yyyy hh:mi:ss&#039;)

Your note indicates that this is working properly.  I assume you insert a row with the $x variable placed in a date, datetime, or string field.  The insert should work with all three field types, but you would handle the fields differently when reading them back into an SQR program.

What type of field is &amp;AUDIT_STAMP?  Since you used to_char successfully, I assume it is a date or datetime field (which is a distinction in PeopleTools, not in the Oracle database).  In that case, you can use to_char, edit, or datetostr to convert it to a string.  You would not use strtodate() - that is a function that starts with a string, and you are starting with a date.

If &amp;AUDIT_STAMP is a string, and you are storing it as a date, you may need datetostr() to format a string to output that date.</description>
		<content:encoded><![CDATA[<p>If you write:</p>
<p>let $x = datenow()</p>
<p>You should make sure that $x is a date variable, not a string variable.  You do that in the setup block:</p>
<p>begin-setup<br />
declare variable<br />
date $x<br />
end-declare<br />
end-setup</p>
<p>Alternately, you could write:</p>
<p>let $x = datetostr(datenow(), &#8216;mm/dd/yyyy hh:mi:ss&#8217;)</p>
<p>Your note indicates that this is working properly.  I assume you insert a row with the $x variable placed in a date, datetime, or string field.  The insert should work with all three field types, but you would handle the fields differently when reading them back into an SQR program.</p>
<p>What type of field is &#038;AUDIT_STAMP?  Since you used to_char successfully, I assume it is a date or datetime field (which is a distinction in PeopleTools, not in the Oracle database).  In that case, you can use to_char, edit, or datetostr to convert it to a string.  You would not use strtodate() &#8211; that is a function that starts with a string, and you are starting with a date.</p>
<p>If &#038;AUDIT_STAMP is a string, and you are storing it as a date, you may need datetostr() to format a string to output that date.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leena</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-7642</link>
		<dc:creator>Leena</dc:creator>
		<pubDate>Fri, 06 Jan 2012 16:50:57 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-7642</guid>
		<description>I need help... I need to insert datetime to a table
No matter what i do, it returns only date
I tried
1. Datenow()
2. Accepting the date, doing to_char and that time it shows correctly, but as soon as i do strtodate, even if i give strtodate(&amp;audit_stamp,&#039;DD-Mon-YYYY HH24:MI:SS&#039;), it will return just the date and not the date time.</description>
		<content:encoded><![CDATA[<p>I need help&#8230; I need to insert datetime to a table<br />
No matter what i do, it returns only date<br />
I tried<br />
1. Datenow()<br />
2. Accepting the date, doing to_char and that time it shows correctly, but as soon as i do strtodate, even if i give strtodate(&amp;audit_stamp,&#8217;DD-Mon-YYYY HH24:MI:SS&#8217;), it will return just the date and not the date time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: administrator</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-6918</link>
		<dc:creator>administrator</dc:creator>
		<pubDate>Sun, 31 Jul 2011 02:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-6918</guid>
		<description>That&#039;s a good point.  Rather than research and develop - and debug - an algorithm to determine unusually dates, we can sometimes find that information in the database.  Or put it in the database ourselves from some external reference.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a good point.  Rather than research and develop &#8211; and debug &#8211; an algorithm to determine unusually dates, we can sometimes find that information in the database.  Or put it in the database ourselves from some external reference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Norma</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-6830</link>
		<dc:creator>Norma</dc:creator>
		<pubDate>Mon, 18 Jul 2011 20:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-6830</guid>
		<description>Normally programs code to the appropriate calendar to get the dates for holidays, bank holidays, country, et. al.  These are delivered in Peoplesoft.  For example, financials open periods shows by product current open accounting periods and fiscal year, then you just go to the detail calendar being used and get dates or use the range.</description>
		<content:encoded><![CDATA[<p>Normally programs code to the appropriate calendar to get the dates for holidays, bank holidays, country, et. al.  These are delivered in Peoplesoft.  For example, financials open periods shows by product current open accounting periods and fiscal year, then you just go to the detail calendar being used and get dates or use the range.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: administrator</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-5976</link>
		<dc:creator>administrator</dc:creator>
		<pubDate>Mon, 16 Aug 2010 16:52:22 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-5976</guid>
		<description>I haven&#039;t worked in SQL Server, but it sounds like it stores dates as the number of days since January 1, 1900.  Dates before then would be negative numbers.  Null dates may be stored as zero, with some flag to distinguish them from 01/01/1900 itself.  Perhaps that flag got lost in your program.  Did you do the inserts with the column variable you read (&amp;TERM_DATE) or did you transfer the value to an SQR variable ($term_date)?  If it was an SQR variable, did you declare it as a date variable?  Your program may have to check for &quot;01/01/1900&quot; and set those dates to null.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t worked in SQL Server, but it sounds like it stores dates as the number of days since January 1, 1900.  Dates before then would be negative numbers.  Null dates may be stored as zero, with some flag to distinguish them from 01/01/1900 itself.  Perhaps that flag got lost in your program.  Did you do the inserts with the column variable you read (&#038;TERM_DATE) or did you transfer the value to an SQR variable ($term_date)?  If it was an SQR variable, did you declare it as a date variable?  Your program may have to check for &#8220;01/01/1900&#8243; and set those dates to null.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Hallas</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-5974</link>
		<dc:creator>Dave Hallas</dc:creator>
		<pubDate>Thu, 12 Aug 2010 11:24:19 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-5974</guid>
		<description>Hi

I&#039;ve hit a problem inserting date values into SQL Server 2005 db - I&#039;m using SQR and am reading values (Termination and Contract End Dt&#039;s) from one table and inserting them into another (interface) table - when there is a value, I have no issue, but when the source table, and therefore the target variable, contains a NULL value, the data is inserted (or interpreted by SQL server) as 01/01/1900.

Any Ideas on how to get around this?

Thanks for the help!</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I&#8217;ve hit a problem inserting date values into SQL Server 2005 db &#8211; I&#8217;m using SQR and am reading values (Termination and Contract End Dt&#8217;s) from one table and inserting them into another (interface) table &#8211; when there is a value, I have no issue, but when the source table, and therefore the target variable, contains a NULL value, the data is inserted (or interpreted by SQL server) as 01/01/1900.</p>
<p>Any Ideas on how to get around this?</p>
<p>Thanks for the help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: administrator</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-1776</link>
		<dc:creator>administrator</dc:creator>
		<pubDate>Fri, 07 Aug 2009 21:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-1776</guid>
		<description>Welcome to the blog, Kevin.  Questions are always welcome.

If you are storing the date in a variable, like this:

let $now = datenow()

you need be declare the variable as a date variable, like this:

begin-setup
declare-variable
date $now
end-declare
end-setup

If you don&#039;t declare $now as a date variable, SQR will make it a string variable.  When you set $now equal to datenow(), SQR will convert the date to a string that looks like a date in your default format.  Then, when you set a database date field to that value, SQR will convert the string to datetime that is 0 seconds after midnight.

You may find it easier to use the built-in database variable for system date and time.  In Oracle, it is SYSDATE.  You could write something like this:

begin-sql
update tablename
set datefield = sysdate
where keyfield = &#039;X&#039;
end-sql</description>
		<content:encoded><![CDATA[<p>Welcome to the blog, Kevin.  Questions are always welcome.</p>
<p>If you are storing the date in a variable, like this:</p>
<p>let $now = datenow()</p>
<p>you need be declare the variable as a date variable, like this:</p>
<p>begin-setup<br />
declare-variable<br />
date $now<br />
end-declare<br />
end-setup</p>
<p>If you don&#8217;t declare $now as a date variable, SQR will make it a string variable.  When you set $now equal to datenow(), SQR will convert the date to a string that looks like a date in your default format.  Then, when you set a database date field to that value, SQR will convert the string to datetime that is 0 seconds after midnight.</p>
<p>You may find it easier to use the built-in database variable for system date and time.  In Oracle, it is SYSDATE.  You could write something like this:</p>
<p>begin-sql<br />
update tablename<br />
set datefield = sysdate<br />
where keyfield = &#8216;X&#8217;<br />
end-sql</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-1772</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Fri, 07 Aug 2009 17:01:24 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-1772</guid>
		<description>Hi,

I have a question about the use of the DATENOW()function in PeopleSoft SQR.  In my pursuit of answers I came across this blog.  I&#039;m not sure asking this question is appropriate, but here goes.

I need to get the current datetime and update a field in a table.  When I use the DATENOW() function I am getting the current date with time of 12:00:00 AM.  Any ideas about what is occurring here

Thanks,
Kevin</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have a question about the use of the DATENOW()function in PeopleSoft SQR.  In my pursuit of answers I came across this blog.  I&#8217;m not sure asking this question is appropriate, but here goes.</p>
<p>I need to get the current datetime and update a field in a table.  When I use the DATENOW() function I am getting the current date with time of 12:00:00 AM.  Any ideas about what is occurring here</p>
<p>Thanks,<br />
Kevin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: administrator</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-423</link>
		<dc:creator>administrator</dc:creator>
		<pubDate>Thu, 21 May 2009 16:24:49 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-423</guid>
		<description>Welcome to my blog, Robert.

The datediff function only works with date variables.  You have to declare them in the setup section like this:

begin-setup
declare-variable
date $eff_dte $pay_end_dt
end-declare
end-setup

Then you need to set their values properly.  If you are getting values from a database table, this is sufficient:

let $eff_dte = &amp;EFFDT
let $pay_end_dt = &amp;PAY_END_DT

But if you get them from any other source, you have to do something like this:

let $eff_dte = strtodate(&#039;05/21/2009&#039;, &#039;mm/dd/yyyy&#039;)
let $pay_end_dt = strtodate(&#039;30-APR-2009&#039;, &#039;dd-mon-yyyy&#039;)

This seems like a lot of work, but I think it&#039;s worth it.  Then your datediff will work and you can write:

if #date_diff &lt; 6

I assume your &quot;if &#039;datediff&#039; &lt; 6&quot; was a typo.  You were comparing a string and a number.</description>
		<content:encoded><![CDATA[<p>Welcome to my blog, Robert.</p>
<p>The datediff function only works with date variables.  You have to declare them in the setup section like this:</p>
<p>begin-setup<br />
declare-variable<br />
date $eff_dte $pay_end_dt<br />
end-declare<br />
end-setup</p>
<p>Then you need to set their values properly.  If you are getting values from a database table, this is sufficient:</p>
<p>let $eff_dte = &amp;EFFDT<br />
let $pay_end_dt = &amp;PAY_END_DT</p>
<p>But if you get them from any other source, you have to do something like this:</p>
<p>let $eff_dte = strtodate(&#8217;05/21/2009&#8242;, &#8216;mm/dd/yyyy&#8217;)<br />
let $pay_end_dt = strtodate(&#8217;30-APR-2009&#8242;, &#8216;dd-mon-yyyy&#8217;)</p>
<p>This seems like a lot of work, but I think it&#8217;s worth it.  Then your datediff will work and you can write:</p>
<p>if #date_diff &lt; 6</p>
<p>I assume your &#8220;if &#8216;datediff&#8217; &lt; 6&#8243; was a typo.  You were comparing a string and a number.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ROBERT O</title>
		<link>http://peoplesoftsqr.com/index.php/2009/04/sqr-dates/comment-page-1/#comment-422</link>
		<dc:creator>ROBERT O</dc:creator>
		<pubDate>Thu, 21 May 2009 14:32:58 +0000</pubDate>
		<guid isPermaLink="false">http://peoplesoftsqr.com/?p=300#comment-422</guid>
		<description>I am looking for help with:

Let #Date_diff = datediff ($Eff_Dte, $Pay_End_Dt, $MONTH) 
    If &#039;datediff&#039; &lt; 6

I am looking to compare employee start date vs. current pay period end date, to check whether a specific earn type was used within 6 months of their start date.

These are the errors I am getting:

Error on line 620:
   (SQR 4045) Function or operator &#039;datediff&#039; requires date argument.

Error on line 620:
   (SQR 4045) Function or operator &#039;datediff&#039; requires date argument.

Error on line 621:
   (SQR 4048) Function or operator &#039;&lt;&#039; must be a string or date argument.

Thanks, Robert.</description>
		<content:encoded><![CDATA[<p>I am looking for help with:</p>
<p>Let #Date_diff = datediff ($Eff_Dte, $Pay_End_Dt, $MONTH)<br />
    If &#8216;datediff&#8217; &lt; 6</p>
<p>I am looking to compare employee start date vs. current pay period end date, to check whether a specific earn type was used within 6 months of their start date.</p>
<p>These are the errors I am getting:</p>
<p>Error on line 620:<br />
   (SQR 4045) Function or operator &#8216;datediff&#8217; requires date argument.</p>
<p>Error on line 620:<br />
   (SQR 4045) Function or operator &#8216;datediff&#8217; requires date argument.</p>
<p>Error on line 621:<br />
   (SQR 4048) Function or operator &#8216;&lt;&#8217; must be a string or date argument.</p>
<p>Thanks, Robert.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

