Comparing LastLogonTimeStamp and current date (DateDiff)

I am looking to modify my working vbscript to only enumerate the users not logged on in a defined variable amount of time. I tried to modify this using the function below, or any variation of, but since removed it as I was unsuccessful. The current script
returns the lastlogontimestamp attribute without issue but I do not have experience with date comparisons. Thank you in advance for your time and assistance.
For Each strUser In objList
If Not objList(strUser) = #1/1/1601# Then
If DateDiff("d", objList(strUser), Now) > 30 Then
Wscript.Echo strUser & " ; " & objList(strUser)
End If
End If
Next
Complete script:
'Craig
Option Explicit
set objFSO = CreateObject("scripting.filesystemobject")
set objFile = objFSO.createtextfile(".\_UserAudit.txt")
Const ADS_UF_ACCOUNTDISABLE = 2
Dim intUAC,strStatus,strDate
Dim objRootDSE, adoConnection, adoCommand, strQuery
Dim adoRecordset, strDNSDomain, objShell, lngBiasKey
Dim lngBias, k, strDN, dtmDate, objDate,objFSO,objFile,dtmPwdLastSet
Dim strBase, strFilter, strAttributes, lngHigh, lngLow,strWhenCreated,strSAM,strpwd,stremployeetype
' Obtain local Time Zone bias from machine registry.
Set objShell = CreateObject("Wscript.Shell")
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
& "TimeZoneInformation\ActiveTimeBias")
If (UCase(TypeName(lngBiasKey)) = "LONG") Then
lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
lngBias = 0
For k = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(k) * 256^k)
Next
End If
Set objShell = Nothing
'strDNSDomain="DC=DMAIN,DC=LOCAL"
'Uncomment so it does the currnet domain it runs in
' Determine DNS domain from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
Set objRootDSE = Nothing
' Use ADO to search Active Directory.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Filter on all user objects.
strFilter = "(&(objectCategory=person)(objectClass=user))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName,samaccountname,lastLogonTimeStamp,useraccountcontrol,pwdLastset,WhenCreated,employeetype"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
' Run the query.
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 60
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
objFile.WriteLine "sAMAccountName;distinguishedName;lastLogonTimestamp;Status;whenCreated;pwdLastSet"
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("distinguishedName").Value
strwhencreated = adoRecordset.Fields("whencreated").Value
strsam = adoRecordset.Fields("samaccountname").Value
stremployeetype = adoRecordset.Fields("employeetype").Value
intUAC=adoRecordset.Fields("userAccountControl").Value
If intUAC AND ADS_UF_ACCOUNTDISABLE Then
strStatus="DISABLED"
Else
strStatus="ENABLED"
End if
If (TypeName(adoRecordset.Fields("pwdLastSet").Value) = "Object") Then
Set objDate = adoRecordset.Fields("pwdLastSet").Value
dtmPwdLastSet = Integer8Date(objDate, lngBias)
Else
dtmPwdLastSet = #1/1/1601#
End If
' Retrieve attribute values for the user.
'strDN = adoRecordset.Fields("samaccountname").Value
' Convert Integer8 value to date/time in current time zone.
On Error Resume Next
Set objDate = adoRecordset.Fields("lastLogonTimeStamp").Value
If (Err.Number <> 0) Then
On Error GoTo 0
dtmDate = #1/1/1601#
Else
On Error GoTo 0
lngHigh = objDate.HighPart
lngLow = objDate.LowPart
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0 ) Then
dtmDate = #1/1/1601#
Else
dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow)/600000000 - lngBias)/1440
End If
End If
' Display values for the user.
If (dtmDate = #1/1/1601#) Then
strDate="Never"
Else
strDate=dtmDate
End If
objFile.WriteLine strsam & ";" & strDN & ";" & strDate & ";" & strStatus & ";" & strwhencreated & ";" & dtmPwdLastSet
adoRecordset.MoveNext
Loop
objFile.WriteLine "Complete"
objFile.Close
Function Integer8Date(ByVal objDate, ByVal lngBias)
' Function to convert Integer8 (64-bit) value to a date, adjusted for
' local time zone bias.
Dim lngAdjust, lngDate, lngHigh, lngLow
lngAdjust = lngBias
lngHigh = objDate.HighPart
lngLow = objdate.LowPart
' Account for error in IADsLargeInteger property methods.
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0) Then
lngAdjust = 0
End If
lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow) / 600000000 - lngAdjust) / 1440
' Trap error if lngDate is ridiculously huge.
On Error Resume Next
Integer8Date = CDate(lngDate)
If (Err.Number <> 0) Then
On Error GoTo 0
Integer8Date = #1/1/1601#
End If
On Error GoTo 0
End Function

Why don't you switch to powershell?
"get-aduser -filter * -properties * | ? {$_.lastlogondate -ge (get-date).adddays(-30)} | 
select samaccountname,enabled,distinguishedname,whencreated,passwordlastset,lastlogondate | 
sort lastlogondate | export-csv 'results.csv' -notypeinformation"
**This is a one-liner command**
Powershell makes it great because you can avoid the hassle of converting values.  For example, lastlogondate is a powershell property.  It's the datetime, human friendly version of the replicated logontimestamp.  The property 'lastlogon' is
the non-replicated value, be sure to use the right one.
The UAC bits don't need converted because PS breaks out the bits into easier to manage properties for us.  
The {$_.lastlogondate....} filter is dynamically grabbing the accounts that have logged in within the last 30 days.  Get today.  Add -30 (30 days ago) and then go greater than that. (-30,-29,-28....today)
Chris Ream

Similar Messages

  • Historic and Current data for Master data bearing objects

    Hi All,
    We are trying to implement type 2 dimensions for all the master data bearing characteristics, where we require historic and current data available for reporting. the master data can have a number of attributes and all of them can be time dependent. We are not getting any 'datefrom' or 'dateto' from the source system.
    For example:
    For Example: The table below shows data entering BI at different dates.
    Source Data day of entering BI
    MasterID ATTR1 ATTR2
    123506 Y REWAR day1
    123506 N REWAR day4
    123506 Y ADJUST day4
    123506 N ADJUST dayn
    The field 'day of entry into BI' is only for your understanding; we do not get any date fields from the source. SID is the field we are generating for uniqueness. It is a counter. EFF_DATE would be the current date for all the data. EXP_DATE would be 31.12.9999 until the attributes change. SID and MasterID together would be the key.
    On day 1 the following data enters BI,
    day 1
    SID MasterID ATTR1 ATTR2 EFF_DATE EXP_DATE
    1 123506 Y REWAR 2/10/2009 12/31/9999
    On day 4, 2 data records enter with same PID,
    SID MasterID ATTR1 ATTR2 EFF_DATE EXP_DATE
    2 123506 N REWAR 2/13/2009 12/31/9999
    3 123506 Y ADJUST 2/13/2009 12/31/9999
    the EXP_DATE of the record of day 1 needs to be changed to current date.
    Also there are two records entering, so latest record would have EXP_DATE as 31.12.9999. And the EXP_DATE of the first record on day 4 should change to the current date.
    so the following changes should happen,
    CHANGE
    SID MasterIDATTR1 ATTR2 EFF_DATE EXP_DATE
    1 123506 Y REWAR 2/10/2009 2/13/2009
    CHANGE
    SID MasterID ATTR1 ATTR2 EFF_DATE EXP_DATE
    3 123506 Y ADJUST 2/13/2009 2/22/2009
    On day n, one data record enters with same PID,
    SID MasterID ATTR1 ATTR2 EFF_DATE EXP_DATE
    4 123506 N ADJUST 2/22/2009 12/31/9999
    The change is ,
    CHANGE
    SID MasterID ATTR1 ATTR2 EFF_DATE EXP_DATE
    3 123506 Y ADJUST 2/13/2009 2/22/2009
    The data expected in P-table is as below, on Day n or after Day n, untill any other record enters for this MasterID,
    1 123506 Y REWAR 2/10/2009 2/13/2009
    2 123506 N REWAR 2/13/2009 2/13/2009
    3 123506 Y ADJUST 2/13/2009 2/22/2009
    4 123506 N ADJUST 2/22/2009 12/31/9999
    Has anyone worked on type 2 dimensions earlier? Or any ideas to implement this logic would be appreciated.
    Regards,
    Sudeepti

    Compound the Master ID with eff date and other attribute as superior objects
    so you will get P-table as
    ATTR1   ATTR2   MAT ID  
    1 2/10/2009 2/13/2009 123506 Y REWAR
    2 2/13/2009 2/13/2009 123506 N REWAR
    3 2/13/2009 2/22/2009 123506 Y ADJUST
    4 2/22/2009 12/31/9999  123506 N ADJUST

  • How to display the username and current date in OAF  page Footer region

    Hi,
    I need to display the username and Current-Date in footer region.If anybody knows the procedure then please share with me.
    Thanks
    Divya Agarwal

    Hi,
    Read this Thread:--
    You have to capture the UserName and Date in the Process Request Method of page Controller and invoke a method which will subsequently get and set the value in some attribute.
    String userName = pageContext.getUserName();
    How to populate Current Date and Time in OAF page through CO
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Increment the version and current date in .ver file

    Hi All,
    I have the version.ver file and it looks like
    [version]
    BuildDates=2014.10.01
    Script=01
    MainVersion=1.00.00.00:01
    I want to increment the values and current date if i trigger the build using batch script. The output i need is like this
    BuildDates=yy.mm.dd (current date)
    Script=02
    MainVersion=1.00.00.00:02
    Thanks in advance

    Thanks for your reply. This is my script
    @echo off>newfile&setlocal enabledelayedexpansion
    :: set up your date here. It probably won't match my format so you'll need to adapt:
    set dt=%date:~10,4%.%date:~7,2%.%date:~4,2%
    for /f "skip=2 tokens=2,3 delims==:" %%a in ("filename") do (
    set v= %%b
    set v= !v: 0=!
    set /a v+=1
    set v=0!v!
    set v=!v:~-2!
    >>newfile echo SCRIPT=!v!
    >>newfile echo BuildDates=%dt%
    >>newfile echo MajorVersion=%%a:!v!
    goto :aa
    :aa
    more +3 "filename" >> newfile
    del "filename"
    ren newfile "filename"
    Before execute the script my file will be look like:
    version]
    BuildDates=date
    Script=09
    MainVersion=3.00.00.00:09
    after executing i am getting the output value as
    BuildDates=date
    Script=01
    MainVersion=19:01
    MainVersion=3.00.00.00:09

  • Pre-populate data and current date only when it routes to that person

    Hi,
    Can  any one please advise how to pre-populate the manager's name when it routes to the manager but not when the user fills the form.
    Example: user fills the form and submit it to the manager, the process has the query to look up for the manager to route it to him for approve/deny. How can I have the manager's name to pre-populate so he/she does not have to type their name and current date to approve/deny the form.
    Thanks in advance,
    Han Dao

    Paul,
    If I have the codes to execute the WS at the initialize event then it does populate the manager info when the user fills the form but when I try to move the code to the pre-submit event which try to execute WS when it route to the manager. I know I did not do it right but have no idea how to make it work.
    Is there a way to execute the WS when it routes to the next person rather than when the user fills the form?
    Thanks,
    Han

  • Compare Hiredate with Current date in PCR

    As per the requirement I have, a certain type of accrual needs to occur on the employee's anniversary date, this accrual should only happen on the first anniversary. How can I compare hire date with current date ignoring the year, and then ignoring the same logic from second year on-wards.
    Can someone please help me with the possible method of implementing this requirement in a time PCR.

    In my humble opinion, I think that you should achieve that by means of an ABAP program, it should be scheduled to run every day and compare the hiring date with the current date of every employee, then create a batch input to Infotype 2013... it would be easier to track and monitor, since you would have all logs in SM35
    Best regards,
    Federico.

  • Previous and current date calculations

    I already have the Date object ( let us say d1 )which is having the past date.
    and I can get the current date anyhow using calendar instance () let us say d2).
    My question is, I want to compare these 2 dates for the month, year and date. it is easy to get the current date, year and month. but I cannot use getMonth(), getDate, getYear() on the Date object, becoz they are deprecated. so, how can i get the month date and year from the date d1 ?
    any help is appreciated.
    u can email me the answer, [email protected]
    Thank you,
    Nisa.

    If you only need to know if d1 is before, equal to, or after d2 you can use d2.compareTo(d1) If 0, they are equal, negative means d2 is before d1, positive means d1 is before d2.
    If you need the actual month, day, or year of either date, then one way is to convet the dates to strings, pass them through a StringTokenizer and grab it's parts that way.

  • How to reference application version number and current date in page footer

    Am new to Apex and am creating first app for production users on Apex 4.0.1 ... I notice that Application Builder app itself displays the version number at bottom right of screen .. are there any substitution strings that I can use to get current date and application version in my own Apex app ... or do I need to create e.g Javascript to format the date and create my own substitution string ?
    Any help much appreciated .. thanks !

    I modified the Footer of our Default page template. Used JavaScript for the date, below is the code we use. The very last table is specific to our environment and it would need to be customized for your use or removed if not needed. I am a JavaScript novice so this may be crude but it does the job.
    Jeff
    <table width="100%" cellpadding="0" cellspacing="0"
    border="0">
    <tr>
    <td width="500">
    <script Language="JavaScript">
    <!--
    function GetDay(nDay)
         var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
                              "Thursday","Friday","Saturday");
         return Days[nDay]
    function GetMonth(nMonth)
         var Months = new Array("January","February","March","April","May","June",
                                "July","August","September","October","November","December");
         return Months[nMonth]             
    function GetTime () {
      var curtime = new Date();
      var curhour = curtime.getHours();
      var curmin = curtime.getMinutes();
      var cursec = curtime.getSeconds();
      var time = "";
      if(curhour == 0) curhour = 12;
      time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
             (curmin < 10 ? "0" : "") + curmin + ":" +
             (cursec < 10 ? "0" : "") + cursec + " " +
             (curhour > 12 ? "PM" : "AM");
      return time;
    function DateString()
         var Today = new Date();
         var suffix = "th";
         switch (Today.getDate())
              case 1:
              case 21:
              case 31:
                   suffix = "st"; break;
              case 2:
              case 22:
                   suffix = "nd"; break;
              case 3:
              case 23:
                   suffix = "rd"; break;
         var strDate = GetDay(Today.getDay()) + " - " + GetMonth(Today.getMonth()) + " " + Today.getDate(); strDate += suffix + ", " + Today.getFullYear() + " " ;
         return strDate
    //-->
    </script>
    <script Language="JavaScript">
    <!--
    document.write(DateString() + GetTime());
    //-->
    </script>
    </td>
    <td width="300" class="fineprint"><div align="right">
    </div></td>
    <td width="900" class="fineprint"><div align="right">
    &APP_USER.
    #APP_VERSION#
    </div></td>
    </tr>
    </table>
    <table width="100%" cellpadding="0" cellspacing="0"
    border="0">
    <tr>
    <td width="33%" align="left" valign="bottom"><img
    src="#WORKSPACE_IMAGES#iconseal-rust.gif" alt="NH State Seal" width="25"
    height="25" /></td>
    <td  width="33%" align="center" valign="bottom"><a href="http://www.nh.gov/" class="fineprint">NH.gov</a>
      <a href="http://www.nh.gov/disclaimer.html"
    class="fineprint">Privacy Policy</a>   <a
    href="http://www.nh.gov/wai/index.html" class="fineprint">Accessibility
    Policy</a></td>
    <td width="33%" class="fineprint"><div align="right">Copyright &#169 State of
    New Hampshire, 2007-2010</div></td>
    </tr>
    </table><br />
    #FORM_CLOSE#
    </body>
    </html>

  • Logotype and Current Date in PDF - Web Applications

    Is possible to insert an image (company logotype) and a text (title and date) in PDF generate through “Printed Version” functionality? The generated PDF only contains result table of the report.
    By the way, how can I insert current date in a web application? I don’t want to use javascript because javascript would return de time/date of the end user computer.
    Thanks in advance.
    Best regards,
    Raphael Barboza

    Hi Raphael,
    Q1) Is possible to insert an image (company logotype) and a text (title and date) in PDF generate through “Printed Version” functionality? The generated PDF only contains result table of the report??
    A)In PDF Print Properties you should be able enter "Title and Date" and also When you define command sequence make sure to call "Analaysis Item only" otherwise the whole template will be downloaded to PDF. Please play with the properties when defining Command Sequence.
    Q2) how can I insert current date in a web application? I don’t want to use javascript because javascript would return de time/date of the end user computer ???
    A) Use Web Template "TEXT ITEM" and in the web item properties "LAST UPDATED or KEY DATE" is the property you should assign.
    Sorry I dont have my system as of now to send you code for these but they are pretty easy.
    thanks,
    Deepak
    SAP BI Consultant
    D N Tech

  • Selection based on previous run date , time and current date a

    HI all,
    I have the selection as follows.
    Previous run date :  .12/14/2005..                     previous run time-14:30:56
    current run date : 12/17/2009.                      current run time: 07:05:31
    Here all are parameters. and  current run date is system date  and   current run time is system time.
    i want to fetch all the deliveries from the above selection including previous run date and time.
    Any inputs..

    Hi
    Append current run data and previous run data into a data range parameter,Current time and previous time into time range parameter and fetch the data based on the range parameters.
    Regards
    Srilaxmi

  • Consecutive Numbering and Current Date

    I am trying to create an invoice (that I will save as a template) and I want the invoice number to change, each time I open the invoice template, to the next consecutive number. I also want the date to stay current each time I open the document. Can anyone help? Thanks in advance.

    MATOS-3802 wrote:
    Thanks for the reply. I am neither familiar with computer lingo nor am I very computer savvy, so a lot of that is really confusing to me. Is there a plain English "numbers for dummies" way of going about it? Thanks again.
    Hi MATOS,
    Fortunately you don't need to understand most of it in order to use it.
    As a user, you need only understand:
    Open the Script Editor.
    Copy Yvan's script from his post, then Paste it into the Script editor.
    Then read this part (assuming your English is stronger than your French). The numbers labeling the sections are used in my notes below:
    Section 1A:
    +++++++
    Save this script as Script : invoiceWithDateAndnumber.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Note 1
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Section 1B
    menu Scripts > Numbers > invoiceWithDateAndnumber
    will create a new document from the defined user template
    and insert a new number and the current date as a fixed value.
    Section 2
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    Section 3
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/06/05
    Section 4
    --=====
    property theApp : "Numbers"
    Adapter ces six “properties” à vos besoins
    Adjust these six properties to fit your needs
    property myTemplate : "my_invoice.nmbtemplate"
    property fichierNum : "the_number.txt"
    property mySheet : "1"
    property myTable : "1"
    property cell4number : "A1"
    property cell4date : "A2"
    --=====
    Section 4 is the beginning of the actual script. You will need to edit the properties list to fit your own situation.
    The first property "theApp" names the application (Numbers) that the script affects. Do not change this.
    Below the line "Adjust these...":
    myTemplate:
    Change "my_invoice.nmbtemplate" to match the name of your Invoice template, and add the ".nmbtemplate" extension to the name.
    fichierNum:
    This is the name of the file that keeps the most recent invoice number. The script will create the file the first time the script is run, and will update it each tome after that. No change is needed in this line.
    mySheet:
    myTable:
    These are currently set to use the first (ie. top of the list) Table on the first sheet of your invoice template. If the template contains only one table (and only one sheet) no change is needed. If your template contains more than one table, you may need adjust the number(s).
    cell4number:
    This is the cell in which the Invoice Number will be placed. Change "A1" to the actual location of the Invoice Number on your template. Remember to enclose the location in double quotes.
    cell4date:
    This is the cell in which the current date will be placed. Change "A2" to the actual location of the Invoice Date on your template. Remember to enclose the location in double quotes.
    In Section 1, Note 1 tells you you will need a specific set of folders in which to place the script.
    In the Finder, open a new window and click on yourAccount (the house icon with your username below it), then on Library, then on Scripts, then on Applications, then on Numbers.
    Each time you click, it opens the folder and shows (in the next column, if your Finder window is in Column view) the items in that folder. If any of the names on this path are missing, you will need to go to the File menu, choose New Folder, and give the new folder the name shown above. (If you have not yet added any scripts, you will likely need to create at least the Applications and Numbers folders.)
    Section 1A tells what to do with the script after you have edited it: Save it in the Numbers folder you created above. You can save it to the Desktop, then move it to the correct folder, or you could save it directly to the correct folder. Yvan's name is chosen to tell exactly what the script does.
    Section 1B tells how to call the script (ie. how to get it to do what it's written to do):
    go to the Scripts Menu, choose Numbers, then choose "invoiceWithDateAndnumber",
    then describes what the script does.
    The Scripts menu is likely not yet in your Menu bar, so Section 2 tells how to get it there. If you, like me, have a crowded Menu bar already, you may also have to remove something else to make room for the Scripts menu.
    Section 3 tells who wrote the script (Yvan) and when he did so.
    Once you've completed those steps (editing properties and saving the script to the correct location), creating a new dated and numbered invoice is a simple matter of choosing this script in the Scripts menu.
    Regards,
    Barry

  • Prompt  with  default  date   (  currentdate-1  and current date-8)

    Dear all,
      I am creating an @prompt varaiable for Date .
    @Prompt('message','type',lov,Mono, free,persistent,default_values)
    Requirement is in Place of "Default Values"   i need show  currentdate -1 and  currentdate-8 .
    Thanks
    suresh.p

    Hi Suresh,
    I have got more idea to do this.
    1 .Build another object of the same field in unv = u201CDate Rangeu201D
    code:
        case when (Date between trunc(sysdate u2013 1) and trunc(sysdate)) then u2018Yesterdayu2019
                 when (Date between trunc(sysdate u2013 8) and trunc(sysdate+1)) then u2018Last 8 Daysu2019
       end
    2. Now Add Yesterday in the defalut for currentdate-1 promp or u2018Last 8 Daysu2019 for currentdate-8 Prompt.
    = @Prompt(u2019Date Pickeru2019,'Au2019,DateX,mono,constrained,persistent,{u2019Yesterdayu2019})
       Create this prompt in the "Date Range" objects. or create a condition, What ever way you want it.
    Please try this and see if this can work without any parsing error.
    Edited by: srrachna on Mar 17, 2011 12:06 PM

  • How to get working Date based on factory Calendar and current date

    Hi All,
    I want to deletermine a date which is Invoice date + 3 working days excluding SAT, SUN and holidays. For e.g, if Invoice date is 18th Sept, 2009, then my desired date should 23rd Sept, 2009.
    I do have factory calendar ID but i dont know the proper function module.
    Can some one please help me...

    Hi,
    check this code,
    DATA:
    w_date   TYPE dats,
    w_date1  LIKE scal-date,               " dats
    w_date2  LIKE scal-date,
    i_factid LIKE tkevs-fcalid VALUE 'IN', " IN for India
    it_dats  TYPE TABLE OF rke_dat,
    wa_dats  LIKE LINE OF it_dats,
    w_lines  TYPE i.
    CALL FUNCTION 'CALCULATE_DATE'
      EXPORTING
        days        = '0'
        months      = '1'
        start_date  = sy-datum             " for example '20090918'
      IMPORTING
        result_date = w_date.              " 1 month added '20091018'
    w_date1 = sy-datum.
    w_date2 = w_date.
    CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
      EXPORTING
        i_datab  = w_date1
        i_datbi  = w_date2
        i_factid = i_factid
      TABLES
        eth_dats = it_dats.                " number of working days between two dates
    READ TABLE it_dats INDEX 4 INTO wa_dats.
    WRITE :
      / wa_dats-periodat.                  " new date '20090923'
    Hope this will be helpfull...
    Regards
    Adil

  • Insert current date/time and username into form.

    Apologies for newbie question.
    I have a form based on table Customer, within the table I have username and modifiedDate columns. How can I populate these text fields with the current user and current date/time ?
    Thanks.

    Excellent, thanks for the fast response. I had this working and then tried in on a new form and now it fails to populate the desired fields.
    I have created a process named "Insert date and username", Type P/SQL anonymous block. On Load - After Header, Once Per Page Visit.
    select :APP_USER, to_char(SYSDATE,'DD-MON-YYYY HH24:MI:SS')
    INTO :P16_USERNAME, :P16_MODIFIEDDATE
    from dual;
    Sorry for the hand holding!
    Jason
    Edited by: Jason S (UK) on Apr 24, 2013 6:57 AM

  • Filtering by current date

    HI
    I am attempting to filter data based on a "date" column
    compared to the current date, depending on certain criteria set by
    the client (example they select "please show all data within last
    day", or perhaps "Show all data previous 7 days").The current date
    has to be set \ updated automaticly and will not be entered by the
    client.
    so, what i need is a filter than can compare data from the
    xml form against the current time.
    I have been able to set this up using php coding, but dont
    know where to start with Spry.
    Any suggests would be greatly appreciated.
    Mark

    i used xpath to filter my lines by month / year, my date
    format is dd.mm.yyyy and an xpath would look like
    /data/line[substring(datum,4,2) = "07" and substring(datum,7,4) =
    "2006"], but this is not really what you want if using ranges (last
    7 days)...
    sorting could be done with dsPhotos.setColumnType("datum",
    "date");
    after sorting (you don't have to sort by date) you could use
    a filter function which compares the date with your given range:
    var myFilterFunc = function(dataSet, row, rowNumber)
    if (PUT YOUR RANGE CONDITION HERE)
    return row; // Return the row to keep it in the data set.
    return null; // Return null to remove the row from the data
    set.
    dsPhotos.filter(myFilterFunc); // Filter the rows in the data
    set.

Maybe you are looking for