web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Generate Week number

(0) ShareShare
ReportReport
Posted on by 3,850

I'm trying to create serial number who combine:

1) Last two digits in year: Year 2013 should be generated as 13.

2) Two digit for week number regarding to current date of creation: 20th - 26th of January 2014 is 04 (week 4 of the year).

3) Six digits start from 000001

My question is: How can I generate the year and week number? These numbers are always combined with "Today" so you don't have the option to manual set dates.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Use the DatePart function to extract the year and another call to extract the week and then combine with your serial number.

    Syntax

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

    The DatePart function syntax has these named arguments:

    Part

    Description

    interval

    Required. String expression that is the interval of time you want to return.

    date

    Required. Variant (Date) value that you want to evaluate.

    firstdayofweek

    Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.

    firstweekofyear

    Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.

    Settings

    The interval argument has these settings:

    Setting

    Description

    yyyy

    Year

    q

    Quarter

    m

    Month

    y

    Day of year

    d

    Day

    w

    Weekday

    ww

    Week

    h

    Hour

    n

    Minute

    s

    Second

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans