Vbs string and date-related functions

Source: Internet
Author: User
Tags month name
Vbs string and date-related functions

Recently, I used date format conversion when writing ASP programs. Because different databases have different requirements on date formats, I have found some relevant information here. I hope it will be helpful to you. If you have any questions, please leave a message, thank you! 1. ASC (x), CHR (x): conversion character, Character Code 2. filter: search for specific string formats in the string array: V = filter (x, s [, include [, compare]) instance: dim X () = {"kjwang ", "wangkj", "Peter"} dim VV = filter (x, "kJ") 'result V (0) = "kjwang", V (1) = "wangkj" V = filter (x, "kJ", false) 'result V (0) = "Peter" V = filter (x, "kJ", true, vbtextcompare) 'case-insensitive search 3. instr: returns the string position (reverse Rev: returns the string). Format: V = instr (x, y) 'locate the position where the y string appears from string x 1st characters v = instr (n, x, y) 'locate the position where the y string appears from the nth character of string X. Format: V = Limit Rev (x, s [, N [, compare]) 4. join: concatenate the string in the format of V = join (X [, d]) 'd to separate the characters 5. len (x): calculates the length format of string X: V = Len (x) 6. left (x, n): returns n characters (corresponding to right (x, n) on the left of string X. mid: The character format in the middle of string X: V = mid (x, n, m) 8. ltrim (x), rtim (x), trim (X) to blank 9. replace: String replacement format: V = Replace (x, S, R) instance: x = "I saw a saw" V = Replace (x, "saw ", "So") 'v = "I so a so" 10. split: string format: V = Split (s [, d]) instance: V = Split ("VB.net, iis6.0, Asp.net", ",") 'result V (0) = "VB.net", V (1) = "iis6.0", V (2) = "Asp.net" 11. strrev Erse: reverse string instance: V = strreverse ("kjwang") 'v = "gnawjk" 12. ucase (x), lcase (x): converts uppercase and lowercase letters. Example: x = "Hello, VB Chinese! "V = ucase (x) 'v =" Hello, VB Chinese!"

'Date-related:

1. extract date and time 1) datevalue (x), timevalue (x) Format: V = datevalue (x): The retrieved "date" section V = timevalue (x) 'Class 2) year (x), month (x), Day (x) Format: V = year (x) V = month (x) V = Day (x) hour (x ), minute (x), second (x): minute, second 3) dateserial (Y, M, d): Merge year, month, and day into date instance: dim VV = dateserial (, 10, 5) 'v = 1996/10/5 timeserial (H, M, S): merging time, minute, and second into time 2. now: Read system Date and Time Format: V = now3. Timer: the number of seconds since 12:00:00 am. Format: V = timer4. datepart (p, X ): obtain the numerical examples of the year, month, and day: dim X = #2/10/1996 16:45:30 # V = datepart ("YYYY", X) 'V = 1996 v = datepart ("M", x) 'v = February v = datepart ("D", X) 'V = 10 V = datepart ("H", x) 'v = 16 V = datepart ("N", X) 'V = 45 minutes v = datepart ("S", x) 'v = 30 seconds v = datepart ("Q", x)' v = Season 1 (first season, spring) V = datepart ("Y", x) 'v = 41 days (1996 days of January 1, 41st) V = datepart ("ww", X) 'V = 6 weeks (1996 weeks of 6th) V = datepart ("W", x) 'v = 7 (6th days of 7th weeks, that is, Saturday) 5. dateadd (p, n, x): the new date and time format after the addition and subtraction is as follows: V = dateadd (p, n, x) 'P values are the same: "YYYY", "M" and other instances: dim X = #1/31/1996 16:45:30 # V = dateadd ("YYYY",-3, x) 'minus 3 years, V = 1993/1/31: 306. datediff (p, x1, x2): calculate the difference between the two Date and time. The value 'P is the same as that of the instance: dim X1 = #12/31/1996 16:45:30 # X2 = #2/10/1997 9:30:50 # V = datediff ("YYYY", x1, x2) 'v = 1 Year 7. formatdatetime: Format of the date and time: V = formatdateyime (X [, Date Format]) Date Format value: dateformat. generaldate, dateformat. longdate, datefotmat. latest date, dateformat. longtime, dateformat. shorttime8. monthname: returned month name instance: V = monthname (5) 'v = "May" 9. weekdayname: the name of the returned Week.

 

Keywords: vbs, date format, string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.