Skip to main content

Notifications

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

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Generate Week number

    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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

#1
Community Member Profile Picture

Community Member 136

#2
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 102 Super User 2025 Season 1

#3
REUser Profile Picture

REUser 8

Featured topics

Product updates

Dynamics 365 release plans