Background: I have a tool that grabs files from a network location based on the file name. There are various files, but the names are all based on the creation date (report052209.txt).

What i need to do is take the date selected from a datetimepicker and save a two digit day, month, and year to seperate variables.

I can't for the life of me get this to work. Just for the sake of practice I've tried creating a form with just a date picker, a button, and a textbox and writting code that will either on display a two digit month in the textbox, or store the two digit month in a variable and display the variable in the text box.

I still want the datetimepicker to display the full date for the user's convenience.

Any help is appreciated.

You can use the Format$ function to pick out individual bits of a date, see code below.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        TextBox1.Text = Format$(Calendar1.SelectedDate, "dd")
        TextBox2.Text = Format$(Calendar1.SelectedDate, "MM")
        TextBox3.Text = Format$(Calendar1.SelectedDate, "yy")
    End Sub

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:Calendar ID="Calendar1" runat="server" ></asp:Calendar>
        <asp:Label ID="Label1" runat="server" Text="Day"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server" Width="58px"></asp:TextBox>
        <asp:Label ID="Label2" runat="server" Text="Month"></asp:Label>
        <asp:TextBox ID="TextBox2" runat="server" Width="61px"></asp:TextBox>
        <asp:Label ID="Label3" runat="server" Text="Year"></asp:Label>
        <asp:TextBox ID="TextBox3" runat="server" Width="47px"></asp:TextBox><br />
        <asp:Button ID="Button1" runat="server" Text="Update" OnClick="Button1_Click" />

ToString() method,

commented: Thanks for the answer - I think I was making it too complicated. +0