Jump to content

Work With Date Parameters


Guest Muslica
 Share

Recommended Posts

Guest Muslica

Hi !

Id like to create the date of yesterday. I thank, I use the $yesterday=@yday-1 formula, but I cant convert to date this format !

M.

Link to comment
Share on other sites

  • Developers

Hi !

Id like to create the date of yesterday. I thank, I use the $yesterday=@yday-1 formula, but I cant convert to date this format !

M.

:huh2: were did i see this before today ????

#16693 :D

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

How about:

$yesterday = @MDAY-1 & "/" & @MON & "/" & @YEAR

If you want the month in figures you need something like this

#include - once
Func MonthName( $MonNum, $Format,$Case )
  
; $Format- 1 = Jan, 0 = January
 ; $Case - 1 = January (Jan), 0 = JANUARY (JAN)
 
 Local $Month[13]
  $msg = "You need to enter a month number" & @CRLF & "and 0 or 1 for the format and case"
  $Month[1]  = "January"
  $Month[2]  = "February"
  $Month[3]  = "March"
  $Month[4]  = "April"
  $Month[5]  = "May"
  $Month[6]  = "June"
  $Month[7]  = "July"
  $Month[8]  = "August"
  $Month[9]  = "September"
  $Month[10] = "October"
  $Month[11] = "November"
  $Month[12] = "December"

  If StringisDigit($MonNum) And $MonNum < 13 And StringisDigit($Format) And _
StringisDigit($Case) Then
    Select
      Case $Format = 0
    Select
    Case $Case = 0
        Return StringUpper($Month[$MonNum])
    Case $Case = 1
    Return $Month[$MonNum]
    Case Else
    SetError( 1 )
        MsgBox(0,"Error",$msg)
    exit
     EndSelect
      Case $Format = 1
    Select
    Case $Case = 0
        Return StringUpper(StringLeft( $Month[$MonNum], 3 ))
    Case $Case = 1
    Return StringLeft( $Month[$MonNum], 3 )
    Case Else
    SetError( 1 )
        MsgBox(0,"Error",$msg)
    exit
     EndSelect
     Case Else
        SetError( 1 )
        MsgBox(0,"Error",$msg)
    exit
    EndSelect
  Else
    SetError( 1 )
    MsgBox(0,"Error",$msg)
    exit
  EndIf
EndFunc

All the best.

[u][font="Arial"]Pete[/font][/u]
Link to comment
Share on other sites

Local $Month[13]
 $msg = "You need to enter a month number" & @CRLF & "and 0 or 1 for the format and case"
 $Month[1]  = "January"
 $Month[2]  = "February"
 $Month[3]  = "March"
 $Month[4]  = "April"
 $Month[5]  = "May"
 $Month[6]  = "June"
 $Month[7]  = "July"
 $Month[8]  = "August"
 $Month[9]  = "September"
 $Month[10] = "October"
 $Month[11] = "November"
 $Month[12] = "December"

After you know Arrays, you can condence the above part of the code like this:

$Month=StringSplit("January,February,March,April,May,June,July,August,September,October,November,December",",")
$msg = "You need to enter a month number" & @CRLF & "and 0 or 1 for the format and case"

Great showing of what the array contains for the example. :D

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...