DatePart: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Brendon (talk | contribs)
No edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.''
DatePart(''interval'', ''date''[, ''firstdayofweek''[, ''firstweekofyear'']])
DatePart(''interval'', ''date''[, ''firstdayofweek''[, ''firstweekofyear'']])


Line 5: Line 7:
DatePart returns a number specifying a part of the given date. The required parameter, ''interval'', determines the part of date which is measured and returned. The optional parameter ''firstdayofweek'' is Sunday, if not specified The optional ''firstweekofyear'' is the week containing January 1, if not specified.
DatePart returns a number specifying a part of the given date. The required parameter, ''interval'', determines the part of date which is measured and returned. The optional parameter ''firstdayofweek'' is Sunday, if not specified The optional ''firstweekofyear'' is the week containing January 1, if not specified.


== Example ==
'''Interval Values'''
 
{| class="wikitable"
|-
! Value !! Description
|-
|  yyyy || Year
|-
| q || Quarter
|-
| m || Month
|-
| y || Day of year
|-
| d || Day
|-
| w || Weekday
|-
| ww || Week of year
|-
| h || Hour
|-
| n || Minute
|-
| s || Second
|}
 
== Example (Basic) ==


<pre>
<pre>
REM DatePart Example
Rem DatePart Example
'DatePart returns a numberfrompartofadate
'DatePart returns a number from part of a date
DIM QuarterPart, MonthPart, DayPart
Dim QuarterPart, MonthPart, DayPart
QuarterPart = DatePart("q", NOW)
QuarterPart = DatePart("q", Now)
MonthPart = DatePart("m", NOW)
MonthPart = DatePart("m", Now)
DayPart = DatePart("d", NOW)
DayPart = DatePart("d", Now)
PRINT "Today is day " & DayPart
Print "Today is day " & DayPart
PRINT "of month " & MonthPart
Print "of month " & MonthPart
PRINT "in quarter " & QuarterPart
Print "in quarter " & QuarterPart
</pre>
</pre>


Line 30: Line 59:
== Related Items ==
== Related Items ==


[[dateadd|DATEADD]], [[datediff|DATEDIFF]]
[[dateadd|DateAdd]], [[datediff|DateDiff]]


[[Category:Language Reference]]
[[Category:Language Reference]]
[[Category:Date and Time]]
[[Category:BASIC Functions]]

Latest revision as of 15:21, 25 March 2019

This function is for BASIC compatibility. It is not available in pure JavaScript projects.

DatePart(interval, date[, firstdayofweek[, firstweekofyear]])

Description

DatePart returns a number specifying a part of the given date. The required parameter, interval, determines the part of date which is measured and returned. The optional parameter firstdayofweek is Sunday, if not specified The optional firstweekofyear is the week containing January 1, if not specified.

Interval Values

Value Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
n Minute
s Second

Example (Basic)

Rem DatePart Example
'DatePart returns a number from part of a date
Dim QuarterPart, MonthPart, DayPart
QuarterPart = DatePart("q", Now)
MonthPart = DatePart("m", Now)
DayPart = DatePart("d", Now)
Print "Today is day " & DayPart
Print "of month " & MonthPart
Print "in quarter " & QuarterPart

Output

Today is day 18
of month 8
in quarter 3
(''sample output from August 18, 1998'')

Related Items

DateAdd, DateDiff