CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Change string value of "20051127" to "11/27/2005"

Print topic Send  topic

Author Message
Guillermo


Posts: 14
Posted: 12/01/2005, 11:14 AM

Hello,
This must be simple... I have this string variable with a value for example of "20051127" and I want to change that value to "11/27/2005". How can I do it con CCS2?

Thanks!
View profile  Send private message
peterr


Posts: 5971
Posted: 12/02/2005, 12:42 AM

I'm not sure where you want to change it. In the database? On the page?
If you want to display dates then usually you would just need to set the "DBFormat" property of a label to the specific date format of your string, then set the "Format" property to the date you want to display.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Stan
Posted: 12/02/2005, 12:53 AM

You should parse this string, using the following format "yyyyMMdd"

DateTime val = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

Or you can use CCS built-in classes

DateField val = new  DateField("yyyyMMdd", "20051127");

Then format it

string sVal  = val.ToString("MM/dd/yyyy");

or

string sVal  = val.GetFormattedValue("MM/dd/yyyy"); 
Guillermo


Posts: 14
Posted: 12/02/2005, 9:48 AM

Hello,
Thanks for the replies... unfortunate I got these errors when compiling the page.

When I use:
DateTime val = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
Error:   
  
M:\DrogueriaCentral_NET\Backups>REM _MakeAll @1-2EF97579   
  
  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1>C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\vbc /rootnamespace:DrogueriaCentral_NET  /t:library /out:bin\DrogueriaCentral_NET.dll /imports:System.Data.OracleClient /r:System.Data.OracleClient.dll /imports:Microsoft.VisualBasic,System,System.Web,System.Xml,System.Data,System.Drawing /r:Microsoft.VisualBasic.dll,System.dll,System.Web.dll,System.Xml.dll,System.Data.dll,System.Drawing.dll /recurse:*.vb   
  
Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4  
  
for Microsoft (R) .NET Framework version 1.1.4322.573  
  
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.  
  
  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30684: 'DateTime' is a type and cannot be used as an expression.  
  
  
  
    DateTime val = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);  
  
    ~~~~~~~~                                                                                                     
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30800: Method arguments must be enclosed in parentheses.  
  
  
  
    DateTime val = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);  
  
             ~~~                                                                                                 
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30516: Overload resolution failed because no accessible 'Val' accepts this number of arguments.  
  
  
  
    DateTime val = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);  
  
             ~~~                                                                                                 
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30037: Character is not valid.  
  
  
  
    DateTime val = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);  
  
                                                                                                              ~  
  
  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1>REM _End MakeAll 

When I use:
DateField val = new DateField("yyyyMMdd", "20051127");

string sVal = val.ToString("MM/dd/yyyy");
or
string sVal = val.GetFormattedValue("MM/dd/yyyy");
Error:   
  
M:\DrogueriaCentral_NET\Backups>REM _MakeAll @1-2EF97579   
  
  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1>C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\vbc /rootnamespace:DrogueriaCentral_NET  /t:library /out:bin\DrogueriaCentral_NET.dll /imports:System.Data.OracleClient /r:System.Data.OracleClient.dll /imports:Microsoft.VisualBasic,System,System.Web,System.Xml,System.Data,System.Drawing /r:Microsoft.VisualBasic.dll,System.dll,System.Web.dll,System.Xml.dll,System.Data.dll,System.Drawing.dll /recurse:*.vb   
  
Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4  
  
for Microsoft (R) .NET Framework version 1.1.4322.573  
  
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.  
  
  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30684: 'DateField' is a type and cannot be used as an expression.  
  
  
  
    DateField val = new  DateField("yyyyMMdd", "20051127");  
  
    ~~~~~~~~~                                                
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30800: Method arguments must be enclosed in parentheses.  
  
  
  
    DateField val = new  DateField("yyyyMMdd", "20051127");  
  
              ~~~                                            
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30516: Overload resolution failed because no accessible 'Val' accepts this number of arguments.  
  
  
  
    DateField val = new  DateField("yyyyMMdd", "20051127");  
  
              ~~~                                            
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(69) : error BC30037: Character is not valid.  
  
  
  
    DateField val = new  DateField("yyyyMMdd", "20051127");  
  
                                                          ~  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(71) : error BC30109: 'String' is a class type, and so is not a valid expression.  
  
  
  
    string sVal  = val.GetFormattedValue("MM/dd/yyyy");       
  
    ~~~~~~                                                    
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(71) : error BC30287: '.' expected.  
  
  
  
    string sVal  = val.GetFormattedValue("MM/dd/yyyy");       
  
           ~~~~                                               
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1\AccountInfo.aspx.vb(71) : error BC30516: Overload resolution failed because no accessible 'Val' accepts this number of arguments.  
  
  
  
    string sVal  = val.GetFormattedValue("MM/dd/yyyy");       
  
                   ~~~                                        
  
  
  
C:\DOCUME~1\GUILLE~1\LOCALS~1\Temp\~DROGU~1>REM _End MakeAll 

Any ideas?
View profile  Send private message
Stan
Posted: 12/05/2005, 12:23 AM

This is C# syntax. For VB you should use

Dim val As DateTime = DateTime.ParseExact("20051127","yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
-or -
Dim val As New DateField("yyyyMMdd", "20051127")

Dim sVal As String = val.ToString("MM/dd/yyyy")
-or-
Dim sVal As String = val.GetFormattedValue("MM/dd/yyyy")

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.