<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Writing a Date expression in PS Query</title>
		<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query</link>
		<description>Posts in the discussion thread &quot;Writing a Date expression in PS Query&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Wed, 08 Feb 2012 21:29:22 +0000</lastBuildDate>
		
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-1353827</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-1353827</link>
				<description></description>
				<pubDate>Thu, 19 Jan 2012 00:16:18 +0000</pubDate>
				<wikidot:authorName>Mary</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>This seems to work when comparing SYSDATE with BIRTHDATE; for example, if you need to find individuals under or over a certain age (only specific to the year, not month or day). Note: You may need to subtract one (year) to stay at or below their current age<br /> (TO_NUMBER(SUBSTR(TO_CHAR(CURRENT_DATE,'YYYY-MM-DD'),1,4)))-(TO_NUMBER(SUBSTR(A.BIRTHDATE,1,4)))<br /> the result is the sysdate year - birthdate year (=age they will become this year)</p> <p>Thanks to all for your help!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-1267945</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-1267945</link>
				<description></description>
				<pubDate>Tue, 27 Sep 2011 08:20:01 +0000</pubDate>
				<wikidot:authorName>John Christy</wikidot:authorName>				<wikidot:authorUserId>1206450</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>How to incorporate the below code in ps query which comes in the where clause..</p> <p>(C.version_dt = select max(D.version_dt) from ps_run_cntrl_tbl D where C.EmplId = D.EmplId and C.Roleuser = D.Roleuser or C.version_dt is null)</p> <p>Thanks in Advance..</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-1233789</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-1233789</link>
				<description></description>
				<pubDate>Fri, 19 Aug 2011 08:55:03 +0000</pubDate>
				<wikidot:authorName>Abhishek</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>to_date(A.HRS_OFR_DT_EXP)-to_date(A.OFFER_DT)<br /> Its Working..</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-1052954</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-1052954</link>
				<description></description>
				<pubDate>Mon, 14 Mar 2011 23:47:50 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Assuming the prompt for YEAR is bind :1, try the following expression in your query:</p> <div class="code"> <pre> <code>to_date('31-DEC-' ||:1, 'DD-MM-YYYY')</code> </pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-1052456</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-1052456</link>
				<description></description>
				<pubDate>Mon, 14 Mar 2011 20:56:21 +0000</pubDate>
				<wikidot:authorName>Paul</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Hi Praj,</p> <p>I'm trying to edit a query that uses a criteria on the year of the most current Effdt. For example, I want data as of 12/31/YEAR where I have a prompt for the year. So that every time the query is ran, it runs for 12/31 of the selected year (2008, 2010, 2011, etc.). Currently, the query has a criteria that prompts for the year and uses the following syntax:</p> <p>'31-DEC-'|| DECODE(:1,' ',TO_CHAR(SYSDATE,'YYYY'),:1)</p> <p>Any thoughts on how to tune this so that I don't get the following error:</p> <p>ORA-01858: a non-numeric character was found where a numeric was expected</p> <p>Any help is appreciated. Thanks! :)</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-884527</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-884527</link>
				<description></description>
				<pubDate>Wed, 29 Sep 2010 10:32:21 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Good to hear you got it all working, thanks for posting the solution.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-883800</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-883800</link>
				<description></description>
				<pubDate>Tue, 28 Sep 2010 16:22:01 +0000</pubDate>
				<wikidot:authorName>Susan</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Praj, thank you for your suggestions. The "=5" was the selection criteria. We wanted to find everyone who had been with the company 5 years. This was not a data issue.</p> <p>The solution was to create 2 expressions - one to display the anniversary and the other to use as selection criteria. Both were defined as Number and neither had any decimals; one expression has a length of 3 the other has a length of 4. The expression with the length of “4” is used to display the anniversary in the query. The expression with the length of “3” is used for the selection criteria. Both expressions had the code:<br /> TRUNC(TRUNC(MONTHS_BETWEEN (SYSDATE, TO_DATE( TO_CHAR(A.CMPNY_SENIORITY_DT,'YYYY-MM-DD'),'YYYY-MM-DD'))) / 12)</p> <p>SQL Errors occur when the expression with the length of “3” is used for display or the length of “4” is used for the selection criteria. It seems to me that this is an Oracle bug. The good news is that we got the query to work.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-878794</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-878794</link>
				<description></description>
				<pubDate>Tue, 21 Sep 2010 22:17:33 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>That syntax looks and seems to work fine in Oracle however, I'm not sure about the <tt>=5</tt> at the end of the view SQL? I figure that was you providing an example of the result and not the actual SQL?</p> <p>One thing that might be causing it is if there are any cases where the A.CMPNY_SENIORITY_DT is invalid? It could simply be some bad data and not the SQL syntax. Perhaps in your where clause include <tt>WHERE A.CMPNY_SENIOR_DT &lt;= sysdate</tt> or equivalent just to check, if it works then data could be the culprit.</p> <p>Another option if you do think it is syntax related is to use meta-SQL to expand the SQL out correctly. For example an expression like this:</p> <div class="code"> <pre> <code>%Truncate((%DateDiff(ASOFDATE, %CurrentDateIn) / 365), 0)</code> </pre></div> <p>This subtracts the current date from the seniority date using <tt>%DateDiff</tt> which returns a value in days. It then divides by 365 (days) truncates off the decimal to return the whole value in years.</p> <p>Hope that helps.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-878600</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-878600</link>
				<description></description>
				<pubDate>Tue, 21 Sep 2010 18:15:31 +0000</pubDate>
				<wikidot:authorName>Susan</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>We need to select those who are having increment of 5 year anniversaries (5, 10, 15, etc). This worked before we converted from Informix to Oracle. Now we can't get the selection criteria to work.</p> <p>The anniversary is derived using the expression:<br /> TO_NUMBER(SUBSTR(TO_CHAR(CURRENT_DATE,'YYYY-MM-DD'),1,4)) - TO_NUMBER(SUBSTR(A.CMPNY_SENIORITY_DT,1,4))<br /> The expression type is Number with Length = 4. The anniversary displays correctly.</p> <p>We run into trouble when trying to create selection criteria where the expression is equal to 5. The error message is: Error in running query because of SQL Error, Code=1722, Message=ORA-01722: invalid number (50,380). Both the left and right side should be considered numeric. This also failed when the expression was defined as character (length 4).</p> <p>View SQL shows the following:<br /> AND TO_NUMBER(SUBSTR(TO_CHAR(CURRENT_DATE,'YYYY-MM-DD'),1,4)) - TO_NUMBER(SUBSTR( A.CMPNY_SENIORITY_DT,1,4)) = 5</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-569824</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-569824</link>
				<description></description>
				<pubDate>Wed, 26 Aug 2009 05:20:04 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Here's an example that's similar to yours that may help.</p> <p>Find all user profiles that were updated in the last year.</p> <p>To do this in SQL:</p> <div class="code"> <div class="hl-main"> <pre> <span class="hl-reserved">select</span><span class="hl-code"> </span><span class="hl-identifier">OPRID</span><span class="hl-code">, </span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code"> </span><span class="hl-reserved">from</span><span class="hl-code"> </span><span class="hl-identifier">PSOPRDEFN</span><span class="hl-code"> </span><span class="hl-reserved">where</span><span class="hl-code"> </span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code"> </span><span class="hl-var">between</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">sysdate</span><span class="hl-code"> - </span><span class="hl-number">365</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-reserved">and</span><span class="hl-code"> </span><span class="hl-identifier">sysdate</span><span class="hl-code"> </span><span class="hl-reserved">order</span><span class="hl-code"> </span><span class="hl-reserved">by</span><span class="hl-code"> </span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code"> </span><span class="hl-reserved">desc</span><span class="hl-code">;</span> </pre></div> </div> <p>So find any user where the last update date/time <tt>LASTUPDDTTM</tt> is greater than or equal to 365 days (1 year) back from the current date, up until the current date.</p> <p>Here's how you would create this expression in PS Query.</p> <table class="wiki-content-table"> <tr> <td><img src="http://peoplesoft.wikidot.com/local--files/images/date-between-one-year-period.png" alt="date-between-one-year-period.png" class="image" /></td> </tr> </table> <p>Note that I've replaced <tt>sysdate</tt> with meta-SQL - <tt>%CurrentDateTimeIn</tt> and <tt>%AddDate(%CurrentDateTimeIn, -365)</tt> to go back 365 days.</p> <p>For the second part, you might want count all user profiles that were updated in the last year, grouped by each month. Here's the SQL you would write to do this:</p> <div class="code"> <div class="hl-main"> <pre> <span class="hl-reserved">select</span><span class="hl-code"> </span><span class="hl-identifier">to_char</span><span class="hl-brackets">(</span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">Month</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-reserved">as</span><span class="hl-code"> </span><span class="hl-reserved">MONTH</span><span class="hl-code">, </span><span class="hl-var">count</span><span class="hl-brackets">(</span><span class="hl-reserved">distinct</span><span class="hl-code"> </span><span class="hl-identifier">OPRID</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-reserved">from</span><span class="hl-code"> </span><span class="hl-identifier">PSOPRDEFN</span><span class="hl-code"> </span><span class="hl-reserved">where</span><span class="hl-code"> </span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code"> &gt;= </span><span class="hl-brackets">(</span><span class="hl-identifier">sysdate</span><span class="hl-code"> - </span><span class="hl-number">365</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-reserved">and</span><span class="hl-code"> </span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code"> &lt;= </span><span class="hl-identifier">sysdate</span><span class="hl-code"> </span><span class="hl-reserved">group</span><span class="hl-code"> </span><span class="hl-reserved">by</span><span class="hl-code"> </span><span class="hl-identifier">to_char</span><span class="hl-brackets">(</span><span class="hl-identifier">LASTUPDDTTM</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">Month</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;</span> </pre></div> </div> <p>The key here is the use of to_char to convert the month part of the <tt>LASTUPDDTTM</tt> field to a month. Here's how you would create the expression:</p> <table class="wiki-content-table"> <tr> <td><img src="http://peoplesoft.wikidot.com/local--files/images/to-month-expression.png" alt="to-month-expression.png" class="image" /></td> </tr> </table> <p>Add this as a field, and perform a count on the <tt>OPRID</tt> field.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-565869</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-565869</link>
				<description></description>
				<pubDate>Fri, 21 Aug 2009 09:15:01 +0000</pubDate>
				<wikidot:authorName>john</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>I am using PSquery to calculate the number of people who have send their resume to the company within a year period. How could I do that using date format in PSQuery?</p> <p>also the number of resume received at the 31 of each month….</p> <p>Thanks for your help</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-388965</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-388965</link>
				<description></description>
				<pubDate>Wed, 18 Feb 2009 17:53:09 +0000</pubDate>
				<wikidot:authorName>Steve</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Hi,</p> <p>Sorry it's taken me a few days to reply.</p> <p>I couldn't get PSQuery to insert this expression without all the other associated code. I gave up in the end and ran it directly against the database via SQL. The end user only wanted a one report so it wasn't too much of a problem.</p> <p>Thanks for you assistance.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-383834</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-383834</link>
				<description></description>
				<pubDate>Fri, 13 Feb 2009 04:49:36 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi,</p> <p>I can't seem to be able to replicate your scenario where the expression you're using as a field:</p> <p><tt>to_char(round(a.effdt - A.LASTUPDDTTM))</tt></p> <p>Suddenly turns to:</p> <p><tt>to_char(round( TO_CHAR(A.EFFDT,'YYYY-MM-DD') - TO_CHAR(CAST((A.LASTUPDDTTM) AS TIMESTAMP),'YYYY-MM-DD-HH24.MI.SS.FF')))</tt></p> <p>In the View SQL tab. Are you using any criteria on your expression field? Can you try removing all fields in your query, then going to the expressions tab, finding your expression and selecting use as a field again?</p> <p>Sometimes PS Query caches the expression and you get the wrong version of it. It <em>should</em> put the expression exactly in line into your SQL.</p> <p>Another thing you can try is:</p> <ul> <li>Create a new private query</li> <li>Add the record PSXLATITEM</li> <li>Select the fields, FIELDNAME, FIELDVALUE, EFFDT, LASTUPDDTTM</li> <li>Create a new expression: <tt>to_char(round(LASTUPDDTTM - EFFDT)) DAYS</tt> as a character with a length of 15 and choose select use as field to make it the fifth field.</li> <li>Have a look at your view SQL and see if that looks right/runs? You might get a maximum rows exceeded error but that's ok, the field should show the number of days.</li> </ul> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-382909</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-382909</link>
				<description></description>
				<pubDate>Thu, 12 Feb 2009 08:23:55 +0000</pubDate>
				<wikidot:authorName>Steve</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Thanks for your reply it's appreciated :).</p> <p>I've modified your expression above to use my field names, it looks as follows:-</p> <p>to_char(round(a.effdt - A.LASTUPDDTTM))</p> <p>I've set the expression type to character and the length to 15. When I run it I receive the following error:-</p> <p>A SQL error occurred. Please consult your system log for details.<br /> Error in running query because of SQL Error, Code=1722, Message=ORA-01722: invalid number (50,380)</p> <p>When I look at the SQL that's been inserted by PSQUERY (View SQL Tab) i see the following for this expression:-</p> <p>to_char(round( TO_CHAR(A.EFFDT,'YYYY-MM-DD') - TO_CHAR(CAST((A.LASTUPDDTTM) AS TIMESTAMP),'YYYY-MM-DD-HH24.MI.SS.FF'))),</p> <p>Any more ideas gratefully received, it's driving me mad. Especially as when you do the same line in SQL it works fine.</p> <p>Thanks<br /> Steve</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-382777</guid>
				<title>Re: Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-382777</link>
				<description></description>
				<pubDate>Thu, 12 Feb 2009 03:41:14 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi,</p> <p>I have written something similar in PS Query to return the processing time for a process/job in the process request table. This query returns the process instance, process name, operator ID, run status, run control ID and processing time (which is process end date/time - process begin date/time expressed as seconds).</p> <p>What you have explained is very close. My processing time expression looks like this:</p> <img src="http://peoplesoft.wikidot.com/local--files/forum:thread/processing-time-query-expression.png" alt="processing-time-query-expression.png" class="image" /> <p>You can ignore the case statement, the key to this is really the following:</p> <p><tt>to_char(round((ENDDTTM - BEGINDTTM) * 24 * 60 * 60))</tt></p> <p>This gives the difference in seconds. However if you just want the answer in days it would be just:</p> <p><tt>to_char(round(ENDDTTM - BEGINDTTM))</tt></p> <p>Which is pretty much exactly what you have. Note the <tt>to_char</tt> is to format the output in character format which PSQuery seems to handle a lot better than numeric format.</p> <p>In terms of formatting instead of messing around with dates I've just used a character expression as I just want to display the number of seconds. I figure you just want the output as the number of days?</p> <p>My Query SQL looks like this:</p> <div class="code"> <div class="hl-main"> <pre> <span class="hl-reserved">SELECT</span><span class="hl-code"> </span><span class="hl-identifier">A</span><span class="hl-code">.</span><span class="hl-identifier">PRCSINSTANCE</span><span class="hl-code"> , </span><span class="hl-identifier">A</span><span class="hl-code">.</span><span class="hl-identifier">PRCSNAME</span><span class="hl-code"> , </span><span class="hl-identifier">TO_CHAR</span><span class="hl-brackets">(</span><span class="hl-identifier">A</span><span class="hl-code">.</span><span class="hl-identifier">RUNDTTM</span><span class="hl-code"> ,</span><span class="hl-quotes">'</span><span class="hl-string">YYYY-MM-DD-HH24.MI.SS."000000"</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code"> , </span><span class="hl-identifier">A</span><span class="hl-code">.</span><span class="hl-identifier">OPRID</span><span class="hl-code"> , </span><span class="hl-identifier">A</span><span class="hl-code">.</span><span class="hl-identifier">RUNSTATUS</span><span class="hl-code"> , </span><span class="hl-identifier">A</span><span class="hl-code">.</span><span class="hl-identifier">RUNCNTLID</span><span class="hl-code"> , </span><span class="hl-brackets">(</span><span class="hl-reserved">CASE</span><span class="hl-code"> </span><span class="hl-reserved">WHEN</span><span class="hl-code"> </span><span class="hl-identifier">ENDDTTM</span><span class="hl-code"> </span><span class="hl-reserved">IS</span><span class="hl-code"> </span><span class="hl-reserved">NULL</span><span class="hl-code"> </span><span class="hl-reserved">THEN</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string">Not Available</span><span class="hl-quotes">'</span><span class="hl-code"> </span><span class="hl-reserved">ELSE</span><span class="hl-code"> </span><span class="hl-identifier">to_char</span><span class="hl-brackets">(</span><span class="hl-identifier">round</span><span class="hl-brackets">((</span><span class="hl-identifier">ENDDTTM</span><span class="hl-code"> - </span><span class="hl-identifier">BEGINDTTM</span><span class="hl-brackets">)</span><span class="hl-code"> * </span><span class="hl-number">24</span><span class="hl-code"> * </span><span class="hl-number">60</span><span class="hl-code"> * </span><span class="hl-number">60</span><span class="hl-brackets">))</span><span class="hl-code"> </span><span class="hl-reserved">END</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-reserved">AS</span><span class="hl-code"> </span><span class="hl-identifier">PROCESSING_TIME</span><span class="hl-code"> </span><span class="hl-reserved">FROM</span><span class="hl-code"> </span><span class="hl-identifier">PSPRCSRQST</span><span class="hl-code"> </span><span class="hl-identifier">A</span> </pre></div> </div> <p>If you try to get the output in date format you'll have all kinds of problems. For example what do you display as the year and month? What about the timestamp? I've found that I really just want the difference expressed as a year, month, day, hour, minute or second value and not in date format at all.</p> <p>Hope that helps.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-129686#post-382437</guid>
				<title>Writing a Date expression in PS Query</title>
				<link>http://www.peoplesoftwiki.com/forum/t-129686/writing-a-date-expression-in-ps-query#post-382437</link>
				<description></description>
				<pubDate>Wed, 11 Feb 2009 20:17:44 +0000</pubDate>
				<wikidot:authorName>Steve</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Hi,</p> <p>I'm trying to write an expression in PSQuery which will subtract two dates from each other and return the difference.</p> <p>If I write the following in SQL it works fine, Select ROUND(A.EFFDT - A.LASTUPDDTTM) from PS_JOB a.</p> <p>However if I try to insert this as an expression in PSQuery I get various error messages about Date formats beingincorrect.</p> <p>I think the problem is the dynamic SQL that's created by PSQuery, i tried added a To_Date conversion into the expression but PS still wirting the SQL as follows:-</p> <p>SELECT TO_DATE( TO_CHAR(A.EFFDT,'YYYY-MM-DD'),'YYYY-MM-DD') - (TO_DATE( TO_CHAR(CAST((A.LASTUPDDTTM) AS TIMESTAMP),'YYYY-MM-DD-HH24.MI.SS.FF'),'YYYY-MM-DD-HH24-MI-SS-FF'))</p> <p>If I don't include the .SS.FF in the mask I receive an error about the date picture, ORA1830 error.</p> <p>Does anybody have any experience of using the last update field on job in HRMS. Or can anybody suggest how I can write the expression in ps query.</p> <p>Thanks<br /> Steve</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>
